/* Portfolio relationship map — Cards/Map toggle, canvas, group frames,
   node cards, edges. Behaviour lives in static/js/properties_map.js. */

/* ── Cards / Map segmented toggle ──────────────────────────────────── */
.map-view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.map-view-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: calc(var(--r-md) - 2px);
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-2);
    white-space: nowrap;
    transition: color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.map-view-toggle button:hover {
    color: var(--fg);
}

.map-view-toggle button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--fg);
    box-shadow: var(--shadow-sm);
}

/* ── Canvas — soft lavender field with a dot grid ──────────────────── */
.portfolio-map {
    position: relative;
    height: 60vh;
    min-height: 380px;
    overflow: hidden;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    background-color: #eef0f9;
    background-image: radial-gradient(rgba(116, 123, 217, 0.28) 1px, transparent 1px);
    background-size: 22px 22px;
    cursor: grab;
    touch-action: none;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
}

@media (min-width: 1024px) {
    .portfolio-map {
        height: 640px;
        max-height: calc(100vh - 220px);
    }
}

.portfolio-map:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent-ring);
}

.portfolio-map.is-panning {
    cursor: grabbing;
}

.portfolio-map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.portfolio-map-edges {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.portfolio-map-groups,
.portfolio-map-nodes {
    position: absolute;
    top: 0;
    left: 0;
}

/* ── Group frames (portfolios + side columns) ──────────────────────── */
.pm-group {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(var(--pm-x, 0px), var(--pm-y, 0px));
    border-radius: 18px;
    background: rgba(124, 131, 224, 0.07);
    border: 1px solid rgba(124, 131, 224, 0.42);
    transition: opacity 300ms ease;
}

.pm-group__label {
    position: absolute;
    top: 12px;
    left: 16px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: calc(100% - 32px);
    font-size: 12px;
    font-weight: 600;
    color: #5e66cf;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.pm-group__label {
    pointer-events: auto;
    cursor: pointer;
}

a.pm-group__label:hover .pm-group__name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.pm-group__dot {
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: currentColor;
    flex-shrink: 0;
}

.pm-group__count {
    font-weight: 400;
    color: rgba(94, 102, 207, 0.65);
}

/* ── Edges — thin dark curves, uniform like a flow tool ────────────── */
.pm-edge {
    fill: none;
    stroke: #535a6e;
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.6;
    transition: opacity 150ms ease, stroke-width 150ms ease;
}

.pm-edge.is-dimmed {
    opacity: 0.08;
}

.pm-edge.is-active {
    opacity: 1;
    stroke-width: 2;
}

/* ── Node = header row + floating white card ───────────────────────── */
.pm-node {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(var(--pm-x, 0px), var(--pm-y, 0px));
    display: block;
    text-align: left;
    transition: opacity 150ms ease;
    cursor: pointer;
}

.pm-node.is-dimmed {
    opacity: 0.22;
}

.pm-node__header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 2px 7px;
    font-size: 11.5px;
}

.pm-node__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    border-radius: 5px;
    border: 1px solid rgba(91, 124, 240, 0.45);
    background: rgba(255, 255, 255, 0.7);
    color: #5b7cf0;
    flex-shrink: 0;
}

.pm-node__kind {
    color: #80849b;
    font-weight: 500;
}

.pm-node__meta {
    margin-left: auto;
    color: #3d4150;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-node__card {
    background: #ffffff;
    border: 1px solid rgba(54, 63, 134, 0.08);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(35, 42, 110, 0.05),
                0 10px 28px rgba(35, 42, 110, 0.08);
    transition: box-shadow 150ms ease, border-color 150ms ease;
}

.pm-node:hover .pm-node__card,
.pm-node:focus-visible .pm-node__card,
.pm-node.is-active .pm-node__card {
    border-color: rgba(91, 124, 240, 0.55);
    box-shadow: 0 2px 4px rgba(35, 42, 110, 0.07),
                0 14px 36px rgba(35, 42, 110, 0.14);
}

.pm-node:focus-visible {
    outline: none;
}

.pm-node__head {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    min-width: 0;
}

.pm-node__dot {
    width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    flex-shrink: 0;
    margin-top: 4px;
}

.pm-node__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.pm-node__sublabel {
    display: block;
    font-size: 10.5px;
    color: var(--fg-3);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* ── Property node ─────────────────────────────────────────────────── */
.pm-node--property {
    width: 256px;
}

.pm-node--property.pm-node--held .pm-node__card {
    border-left: 3px solid var(--pm-structure-color, var(--border));
}

.pm-node--property.pm-node--sold .pm-node__card {
    filter: saturate(0.4);
}

.pm-node__img {
    height: 92px;
    background-size: cover;
    background-position: center;
    background-color: var(--surface-2);
    border-bottom: 1px solid rgba(54, 63, 134, 0.08);
    position: relative;
}

.pm-node__sold-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 7px;
    border-radius: var(--r-sm);
    background: #fef3c7;       /* amber-100, mirrors the card badge */
    color: #92400e;            /* amber-800 */
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pm-node__sold-badge--inline {
    position: static;
    flex-shrink: 0;
    margin-left: auto;
}

.pm-node__body {
    padding: 11px 13px 12px;
}

.pm-node__stats {
    margin-top: 9px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.pm-node__stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
}

.pm-node__stat-label {
    color: var(--fg-2);
}

.pm-node__stat-value {
    color: var(--fg);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pm-node__stat-value.pos { color: #059669; }   /* emerald-600 */
.pm-node__stat-value.neg { color: #ef4444; }   /* red-500 */

.pm-node__loan {
    margin-top: 10px;
    padding: 5px 8px;
    border-radius: var(--r-sm);
    background: rgba(124, 131, 224, 0.08);
    font-size: 10.5px;
    color: var(--fg-2);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-node__loan svg {
    flex-shrink: 0;
    color: #5b7cf0;
}

/* ── Structure / scenario nodes ────────────────────────────────────── */
.pm-node--structure {
    width: 196px;
}

.pm-node--structure .pm-node__card {
    border-left: 3px solid var(--pm-structure-color, var(--border-strong));
}

.pm-node--structure .pm-node__body,
.pm-node--scenario .pm-node__body {
    padding: 10px 13px 11px;
}

.pm-node--scenario {
    width: 204px;
}

/* ── Floating controls ─────────────────────────────────────────────── */
.portfolio-map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.portfolio-map-controls button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--r-md);
    background: #ffffff;
    border: 1px solid rgba(54, 63, 134, 0.12);
    box-shadow: 0 1px 3px rgba(35, 42, 110, 0.08);
    color: var(--fg-2);
    transition: color 150ms ease, background-color 150ms ease;
}

.portfolio-map-controls button:hover {
    color: var(--fg);
    background: var(--surface-2);
}

/* ── Legend ────────────────────────────────────────────────────────── */
.portfolio-map-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 10;
    pointer-events: none;
}

.portfolio-map-legend__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    background: #ffffff;
    border: 1px solid rgba(54, 63, 134, 0.12);
    box-shadow: 0 1px 3px rgba(35, 42, 110, 0.08);
    font-size: 10.5px;
    color: var(--fg-2);
}

.portfolio-map-legend__dot {
    width: 7px;
    height: 7px;
    border-radius: var(--r-full);
}

.portfolio-map-legend__dot--structure { background: #8b5cf6; }
.portfolio-map-legend__dot--property  { background: #10b981; }
.portfolio-map-legend__dot--scenario  { background: var(--fg-3); }

/* Portfolio = group frame, so its legend swatch is a tiny frame */
.portfolio-map-legend__swatch {
    width: 11px;
    height: 9px;
    border-radius: 3px;
    background: rgba(124, 131, 224, 0.15);
    border: 1px solid rgba(124, 131, 224, 0.6);
}

/* ── Entrance animation (gated on reduced motion) ──────────────────── */
@media (prefers-reduced-motion: no-preference) {
    .pm-node.pm-enter {
        opacity: 0;
        transform: translate(var(--pm-x), calc(var(--pm-y) + 8px));
    }

    .pm-node.pm-enter-in {
        opacity: 1;
        transform: translate(var(--pm-x), var(--pm-y));
        transition: opacity 300ms ease var(--pm-delay, 0ms),
                    transform 300ms ease var(--pm-delay, 0ms);
    }

    .pm-group.pm-enter {
        opacity: 0;
    }

    .pm-group.pm-enter-in {
        opacity: 1;
        transition: opacity 350ms ease;
    }

    .pm-edge.pm-enter {
        opacity: 0;
    }

    .pm-edge.pm-enter-in {
        opacity: 0.6;
        transition: opacity 400ms ease 250ms;
    }
}

/* Flash highlight when the map links to the scenarios section */
.pm-flash {
    animation: pm-flash 1.2s ease;
}

@keyframes pm-flash {
    0%, 100% { box-shadow: var(--shadow-card); }
    25% { box-shadow: 0 0 0 3px var(--accent-ring); }
}

/* ── AI chat panel (right of the map, UI preview) ──────────────────── */
.pmap-layout {
    display: flex;
    align-items: stretch;
}

.pmap-layout .portfolio-map {
    flex: 1 1 auto;
    min-width: 0;
}

/* Resize handle */
.pmap-resize-handle {
    width: 4px;
    flex-shrink: 0;
    background: var(--border);
    cursor: col-resize;
    position: relative;
    transition: background 0.15s;
    touch-action: none;
}
.pmap-resize-handle::before {
    content: '';
    position: absolute;
    inset: 0 -5px;
}
.pmap-resize-handle:hover,
.pmap-resize-handle--active {
    background: var(--border-strong, #94a3b8);
}

.pmap-chat {
    width: 600px; /* matches the resize handle's max (properties_map.js) */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
}

@media (min-width: 1024px) {
    .pmap-layout .portfolio-map {
        border-radius: 0 0 0 var(--r-lg);
    }
}

@media (max-width: 1023.98px) {
    .pmap-layout {
        flex-direction: column;
    }
    .pmap-layout .portfolio-map {
        border-radius: 0;
    }
    .pmap-chat {
        width: auto !important;
        height: 420px;
        border-top: 1px solid var(--border);
        border-radius: 0 0 var(--r-lg) var(--r-lg);
    }
    .pmap-resize-handle {
        display: none;
    }
}

/* ── Chat header ─────────────────────────────────────────────────── */
.pmap-chat__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    height: 40px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.pmap-chat__title {
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-2);
    flex: 1;
}

.pmap-chat__badge {
    padding: 2px 6px;
    border-radius: var(--r-full);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-3);
}

/* ── Messages ────────────────────────────────────────────────────── */
.pmap-chat__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.pmap-chat__empty {
    margin: auto;
    text-align: center;
    padding: 32px 20px;
}

.pmap-chat__empty-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--fg);
    margin-bottom: 8px;
}

.pmap-chat__empty-hint {
    font-size: 13px;
    line-height: 1.6;
    color: var(--fg-3);
}

/* Date separator between history groups */
.pmap-msg__separator {
    text-align: center;
    font-size: 10px;
    color: var(--fg-3);
    padding: 12px 14px 4px;
}

/* Copilot-style rows: user = right-aligned bubble, assistant = plain text */
.pmap-msg {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pmap-msg--user {
    align-items: flex-end;
}

.pmap-msg--user .pmap-msg__text {
    background: var(--surface-2);
    border-radius: 16px;
    padding: 9px 14px;
    max-width: 88%;
}

.pmap-msg__label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--fg-3);
}

.pmap-msg__time {
    font-weight: 500;
    letter-spacing: 0.1em;
    margin-left: 4px;
}

.pmap-msg__text {
    font-size: 13px;
    line-height: 1.65;
    color: var(--fg);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.pmap-msg__context {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Reasoning loader — flashing sparkle + shimmering text */
.pmap-reasoning {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 2px 0;
}

.pmap-reasoning__spark {
    font-size: 14px;
    line-height: 1;
    color: var(--fg-2);
    animation: pmap-spark 1.2s ease-in-out infinite;
}

@keyframes pmap-spark {
    0%, 100% { opacity: 0.25; transform: scale(0.85) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.15) rotate(90deg); }
}

.pmap-reasoning__text {
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(90deg,
        var(--fg-3) 0%, var(--fg) 50%, var(--fg-3) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: pmap-shimmer 1.6s linear infinite;
}

@keyframes pmap-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ── Composer ────────────────────────────────────────────────────── */
.pmap-chat__composer {
    position: relative;
    flex-shrink: 0;
    background: var(--surface);
    padding: 8px 12px 12px;
}

/* Template starter pills (Rentvest, Goal planner, Hazard review…) */
.pmap-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 8px;
}

.pmap-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: var(--r-full, 999px);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--fg-2);
    cursor: pointer;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.pmap-suggestion:hover {
    color: var(--fg);
    background: var(--surface-2);
    border-color: var(--border-strong, var(--border));
}

.pmap-suggestion__spark {
    font-size: 10px;
    color: var(--fg-3);
    transition: color 0.12s;
}

.pmap-suggestion:hover .pmap-suggestion__spark {
    color: var(--fg);
}

/* Rounded frame around the input area so it reads as the composer */
.pmap-chat__box {
    display: flex;
    flex-direction: column;
    border: 1.5px solid var(--border-strong, var(--border));
    border-radius: 18px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pmap-chat__box:focus-within {
    border-color: var(--fg-3);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 6%, transparent);
}

.pmap-chat__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 8px 12px 0;
    min-height: 0;
}

.pmap-chat__chips:empty {
    padding: 0;
}

.pmap-chat__addctx {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px 2px 5px;
    border-radius: 5px;
    border: 1px dashed var(--border-strong, var(--border));
    font-size: 11px;
    font-weight: 500;
    color: var(--fg-3);
    cursor: pointer;
    transition: color 0.12s, background 0.12s, border-style 0.12s;
    background: transparent;
}

.pmap-chat__addctx:hover,
.pmap-chat__addctx[aria-expanded="true"] {
    color: var(--fg);
    background: var(--surface-2);
    border-style: solid;
}

/* Chips — Cursor-style: icon + label pill, × replaces the icon on hover */
.pmap-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 180px;
    padding: 2px 7px 2px 5px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 500;
    color: var(--fg-2);
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.pmap-chip:hover {
    color: var(--fg);
    border-color: var(--border-strong, var(--border));
    background: var(--surface-2);
}

.pmap-chip__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.pmap-chip--structure .pmap-chip__icon { color: #8b5cf6; }
.pmap-chip--property  .pmap-chip__icon { color: #10b981; }
.pmap-chip--scenario  .pmap-chip__icon { color: #64748b; }

.pmap-chip__label {
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Removable chips: hide the × until hover, then swap it into the icon's
   slot so the chip doesn't change width (like Cursor's context pills). */
.pmap-chip__remove {
    display: none;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    color: var(--fg-3);
    cursor: pointer;
    transition: color 0.12s, background 0.12s;
    flex-shrink: 0;
    order: -1;
}

.pmap-chip:has(.pmap-chip__remove):hover .pmap-chip__icon,
.pmap-chip:has(.pmap-chip__remove):focus-within .pmap-chip__icon {
    display: none;
}

.pmap-chip:hover .pmap-chip__remove,
.pmap-chip:focus-within .pmap-chip__remove {
    display: inline-flex;
}

.pmap-chip__remove:hover {
    color: var(--fg);
    background: var(--border);
}

/* Context chips echoed above a sent user message: smaller and muted */
.pmap-msg__context .pmap-chip {
    font-size: 10.5px;
    padding: 1.5px 6px 1.5px 4px;
    background: var(--surface);
    color: var(--fg-3);
}

.pmap-msg__context .pmap-chip:hover {
    color: var(--fg-2);
    background: var(--surface);
}

/* Textarea */
.pmap-chat__input {
    display: block;
    width: 100%;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    padding: 10px 14px 6px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--fg);
    max-height: 120px;
    font-family: inherit;
}

.pmap-chat__input::placeholder {
    color: var(--fg-3);
}

/* Footer row */
.pmap-chat__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 10px 10px;
    gap: 8px;
}

.pmap-chat__hint {
    font-size: 10px;
    color: var(--fg-3);
    flex: 1;
}

/* @ hint shown in foot when user can type @ */
.pmap-chat__at-hint {
    font-size: 10px;
    color: var(--fg-3);
    display: flex;
    align-items: center;
    gap: 3px;
}

.pmap-chat__at-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 10px;
    font-family: inherit;
    color: var(--fg-2);
    line-height: 16px;
}

.pmap-chat__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--r-full, 999px);
    background: var(--fg);
    color: var(--surface);
    cursor: pointer;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.pmap-chat__send:hover:not(:disabled) {
    opacity: 0.8;
}

.pmap-chat__send:disabled {
    opacity: 0.2;
    cursor: default;
}

/* ── Context picker ───────────────────────────────────────────────── */
.pmap-picker {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% - 4px);
    /* Above Leaflet panes/controls (z-index 400-1000) in hazard cards */
    z-index: 1100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.04), 0 16px 40px rgba(0,0,0,0.12);
    overflow: hidden;
}

.pmap-picker__search {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    outline: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--fg);
    font-family: inherit;
}

.pmap-picker__search::placeholder {
    color: var(--fg-3);
}

/* Hide search input when picker is triggered by @ (textarea acts as filter) */
.pmap-picker[data-at-mode] .pmap-picker__search {
    display: none;
}

.pmap-picker__list {
    max-height: 224px;
    overflow-y: auto;
    padding: 4px;
}

.pmap-picker__group {
    padding: 6px 8px 2px;
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--fg-3);
}

.pmap-picker__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border-radius: 7px;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
    background: transparent;
    border: 0;
}

.pmap-picker__item:hover,
.pmap-picker__item[aria-selected="true"] {
    background: var(--surface-2);
}

.pmap-picker__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.pmap-picker__icon--structure {
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.06);
}
.pmap-picker__icon--property {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.06);
}
.pmap-picker__icon--scenario {
    color: #64748b;
}

.pmap-picker__text {
    flex: 1;
    min-width: 0;
}

.pmap-picker__label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pmap-picker__hint {
    flex-shrink: 0;
    font-size: 10.5px;
    color: var(--fg-3);
    white-space: nowrap;
}

.pmap-picker__none {
    padding: 14px;
    text-align: center;
    font-size: 12px;
    color: var(--fg-3);
}

/* ── Dedicated map page ───────────────────────────────────────────── */

body:has(.pmap-page) {
    overflow: hidden;
}

.pmap-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.pmap-page__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 52px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    overflow-x: auto;
}

.pmap-page__bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
}

.pmap-page__back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--fg-2);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.pmap-page__back:hover {
    background: var(--surface-2);
    color: var(--fg);
}

.pmap-page__divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    flex-shrink: 0;
}

.pmap-page__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
    white-space: nowrap;
}

.pmap-page__tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.pmap-page__tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--fg-2);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.pmap-page__tab:hover {
    background: var(--surface-2);
    color: var(--fg);
}
.pmap-page__tab--active {
    background: var(--surface-2);
    color: var(--fg);
}

.pmap-page__tab-count {
    font-size: 10.5px;
    color: var(--fg-3);
    tabular-nums: initial;
}

.pmap-page__body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.pmap-page__empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--fg-2);
}

/* Full-height layout variant for the dedicated map page */
.pmap-layout--full {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    align-items: stretch;
}

.pmap-layout--full .portfolio-map {
    height: 100%;
    min-height: 0;
    max-height: none;
    border-radius: 0;
}

@media (max-width: 1023.98px) {
    .pmap-page__bar {
        flex-wrap: nowrap;
    }
    .pmap-page__body {
        flex-direction: column;
    }
    .pmap-layout--full {
        flex-direction: column;
    }
    .pmap-layout--full .portfolio-map {
        flex: 1 1 auto;
        height: auto;
    }
    .pmap-layout--full .pmap-chat {
        height: 380px;
        flex-shrink: 0;
    }
}
