.tool-layout.tool-layout-immersive:has(.map-studio) {
    display: block;
    max-width: 1180px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.tool-layout.tool-layout-immersive:has(.map-studio) > .tool-sidebar { display: none; }

.map-studio {
    --ms-bg: #07111f;
    --ms-panel: rgba(8, 16, 32, 0.92);
    --ms-line: rgba(148, 163, 184, 0.22);
    --ms-text: #e8eef8;
    --ms-dim: #94a3b8;
    --ms-accent: #22d3ee;
    --ms-accent-2: #38bdf8;
    color: var(--ms-text);
    background:
        radial-gradient(1200px 420px at 10% -10%, rgba(34, 211, 238, 0.16), transparent 55%),
        linear-gradient(180deg, #0b1730 0%, #07111f 100%);
    border: 1px solid var(--ms-line);
    border-radius: 22px;
    padding: 14px;
    box-shadow: 0 24px 60px rgba(2, 8, 23, 0.35);
}

.map-studio-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.map-search {
    position: relative;
    flex: 1 1 280px;
    min-width: 220px;
}

.map-search input,
.map-coord input,
.map-studio select {
    width: 100%;
    border: 1px solid var(--ms-line);
    background: rgba(15, 23, 42, 0.75);
    color: var(--ms-text);
    border-radius: 12px;
    padding: 0.72rem 0.9rem;
    font: inherit;
    outline: none;
}

.map-search input:focus,
.map-coord input:focus,
.map-studio select:focus {
    border-color: var(--ms-accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.map-search-list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #0f172a;
    border: 1px solid var(--ms-line);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    max-height: 280px;
    overflow: auto;
}

.map-search-list[hidden] { display: none; }

.map-search-list button {
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--ms-text);
    border: 0;
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
}

.map-search-list button:hover,
.map-search-list button:focus { background: rgba(34, 211, 238, 0.12); }

.map-search-list small { display: block; color: var(--ms-dim); }

.map-actions,
.map-mode {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.map-studio button,
.map-chip {
    border: 1px solid var(--ms-line);
    background: rgba(15, 23, 42, 0.72);
    color: var(--ms-text);
    border-radius: 999px;
    padding: 0.55rem 0.85rem;
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
    line-height: 1.2;
}

.map-studio button:hover,
.map-chip:hover { border-color: rgba(56, 189, 248, 0.7); }

.map-studio button[aria-pressed="true"],
.map-chip[aria-pressed="true"],
.map-mode button[aria-pressed="true"] {
    background: linear-gradient(180deg, #22d3ee, #0284c7);
    color: #042033;
    border-color: transparent;
    font-weight: 700;
}

.map-style-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
}

.map-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 12px;
    align-items: stretch;
}

.map-stage > * {
    min-width: 0;
}

.map-frame {
    position: relative;
    min-height: 420px;
    height: clamp(420px, 68vh, 760px);
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--ms-line);
    background: #020617;
    min-width: 0;
}

.map-frame > .map-canvas,
.map-canvas.maplibregl-map,
.map-canvas.leaflet-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
}

.map-canvas .maplibregl-canvas-container,
.map-canvas .maplibregl-canvas {
    width: 100% !important;
    height: 100% !important;
}

.map-float {
    position: absolute;
    z-index: 5;
    right: 12px;
    top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-float button {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 12px;
    background: rgba(8, 16, 32, 0.88);
    font-size: 1.1rem;
}

.map-readout {
    position: absolute;
    z-index: 5;
    left: 12px;
    bottom: 12px;
    max-width: min(420px, calc(100% - 24px));
    background: rgba(8, 16, 32, 0.88);
    border: 1px solid var(--ms-line);
    border-radius: 14px;
    padding: 0.65rem 0.8rem;
    font-size: 0.84rem;
}

.map-readout strong { color: var(--ms-accent); }

.map-panel {
    background: var(--ms-panel);
    border: 1px solid var(--ms-line);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.map-panel h2 {
    margin: 0;
    font-size: 1rem;
}

.map-panel p,
.map-note {
    margin: 0;
    color: var(--ms-dim);
    font-size: 0.82rem;
}

.map-coord { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.map-sliders label {
    display: grid;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--ms-dim);
}

.map-sliders input[type="range"] { width: 100%; }

.map-pin-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
    max-height: 220px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-pin-list li {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    background: rgba(15, 23, 42, 0.65);
    border-radius: 12px;
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
}

.map-pin-list button {
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
}

.map-panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.leaflet-container { font: inherit; background: #020617; }
.maplibregl-ctrl-attrib, .leaflet-control-attribution {
    background: rgba(8, 16, 32, 0.8) !important;
    color: #cbd5e1 !important;
    font-size: 11px !important;
}
.maplibregl-ctrl-attrib a, .leaflet-control-attribution a { color: #7dd3fc !important; }

@media (max-width: 1180px) {
    .map-stage { grid-template-columns: 1fr; justify-items: center; }
    .map-frame {
        width: min(100%, 860px);
        margin-inline: auto;
        height: min(68vh, 640px);
        min-height: 360px;
    }
    .map-panel { width: min(100%, 860px); }
    .map-pin-list { max-height: 160px; }
}

@media (max-width: 640px) {
    .map-studio { padding: 10px; border-radius: 16px; }
    .map-frame { height: min(58vh, 480px); min-height: 280px; }
    .map-actions button, .map-mode button, .map-chip { padding: 0.5rem 0.7rem; }
}
