:root {
            --safe-t: env(safe-area-inset-top, 0px);
            --safe-b: env(safe-area-inset-bottom, 0px);
            --safe-l: env(safe-area-inset-left, 0px);
            --safe-r: env(safe-area-inset-right, 0px);
            --bg: #0b1220;
            --glass: rgba(12, 18, 32, 0.82);
            --line: rgba(148, 163, 184, 0.22);
            --text: #e8eef7;
            --muted: #94a3b8;
            --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
            --fab-size: 54px;
            --fab-stack-gap: 8px;
            --fab-from-edge: max(12px, calc(12px + var(--safe-l)));
            --fab-from-edge-r: max(12px, calc(12px + var(--safe-r)));
            --fab-from-bottom: max(22px, calc(22px + var(--safe-b)));
            --fab-from-top: max(12px, calc(12px + var(--safe-t)));
            --ease-spring: cubic-bezier(0.2, 0.85, 0.2, 1);
            --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
            --radius-sheet-top: 24px;
            --radius-fab: 16px;
        }
        * { box-sizing: border-box; }
        html, body {
            margin: 0;
            min-height: 100%;
            min-height: 100dvh;
            height: 100%;
            background: var(--bg);
            color: var(--text);
            font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
            overflow: hidden;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
            -webkit-font-smoothing: antialiased;
            color-scheme: dark;
        }
        #knm-engine {
            position: fixed;
            inset: 0;
            width: 100vw;
            height: 100vh;
            height: 100dvh;
            border: 0;
            z-index: 1;
            background: #0a0a0f;
            pointer-events: auto;
        }
        #knm-chrome {
            position: fixed;
            inset: 0;
            z-index: 89;
            pointer-events: none;
        }
        #knm-chrome .hit {
            pointer-events: auto;
        }
        .fab-stack {
            position: fixed;
            z-index: 90;
            display: flex;
            flex-direction: column;
            gap: max(8px, var(--fab-stack-gap));
            align-items: stretch;
        }
        .fab-stack.tl {
            top: var(--fab-from-top);
            left: var(--fab-from-edge);
        }
        .fab-stack.tr {
            top: var(--fab-from-top);
            right: var(--fab-from-edge-r);
            align-items: flex-end;
        }
        .fab-stack.bl {
            bottom: var(--fab-from-bottom);
            left: var(--fab-from-edge);
        }
        .fab-stack.br {
            bottom: var(--fab-from-bottom);
            right: var(--fab-from-edge-r);
            align-items: flex-end;
        }
        .fab {
            width: var(--fab-size);
            height: var(--fab-size);
            min-width: var(--fab-size);
            padding: 0;
            box-sizing: border-box;
            border-radius: var(--radius-fab);
            background: rgba(12, 18, 28, 0.42);
            border: 1px solid rgba(255, 255, 255, 0.045);
            color: var(--text);
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition:
                transform 0.2s var(--ease-out),
                background 0.2s var(--ease-out),
                border-color 0.2s var(--ease-out),
                box-shadow 0.2s var(--ease-out);
        }
        @media (hover: hover) {
            .fab:hover {
                background: rgba(18, 26, 38, 0.55);
            }
        }
        .fab:active {
            transform: scale(0.96);
        }
        .fab.secondary {
            background: rgba(12, 18, 28, 0.36);
            border-color: rgba(255, 255, 255, 0.04);
        }
        @media (hover: hover) {
            .fab.secondary:hover {
                background: rgba(18, 26, 38, 0.5);
            }
        }
        .fab.on {
            color: #f0f9ff;
            background: linear-gradient(180deg, rgba(37, 99, 235, 0.82), rgba(30, 64, 175, 0.88));
            border-color: rgba(96, 165, 250, 0.42);
            box-shadow:
                0 0 0 1px rgba(96, 165, 250, 0.1),
                0 4px 16px rgba(37, 99, 235, 0.22);
        }
        @media (hover: hover) {
            .fab.on:hover {
                background: linear-gradient(180deg, rgba(45, 110, 240, 0.88), rgba(34, 72, 190, 0.92));
            }
        }
        .fab--icon {
            flex-direction: column;
            gap: 3px;
            letter-spacing: 0;
            font-size: 0;
            line-height: 0;
        }
        .fab--icon .fab-ic {
            width: 20px;
            height: 20px;
            flex-shrink: 0;
            opacity: 0.9;
            color: rgba(248, 250, 252, 0.92);
        }
        .fab--icon .fab-lbl {
            font-size: 8px;
            font-weight: 600;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            color: rgba(226, 232, 240, 0.72);
            line-height: 1;
        }
        .coord-chip {
            position: fixed;
            z-index: 85;
            top: calc(var(--fab-from-top) + var(--fab-size) + 10px);
            right: max(12px, calc(12px + var(--safe-r)));
            width: auto;
            max-width: 160px;
            min-width: 0;
            height: auto;
            padding: 7px 10px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.035);
            background: rgba(10, 16, 26, 0.28);
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            display: flex;
            flex-direction: column;
            gap: 2px;
            font-size: 10px;
            font-weight: 700;
            line-height: 1.2;
            pointer-events: none;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
            text-align: right;
        }
        .coord-chip .lines {
            display: flex;
            flex-direction: column;
            gap: 2px;
            align-items: flex-end;
            min-width: 0;
        }
        .coord-chip .lines > span {
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-variant-numeric: tabular-nums;
        }
        .coord-chip .acc {
            margin: 0;
            color: rgba(167, 243, 208, 0.88);
            font-weight: 700;
        }
        .brand-wrap {
            position: fixed;
            z-index: 74;
            top: max(14px, calc(14px + var(--safe-t)));
            left: 50%;
            transform: translateX(-50%);
            width: auto;
            height: auto;
            padding: 0;
            background: none;
            border: none;
            box-shadow: none;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            pointer-events: none;
        }
        .brand-logo {
            display: block;
            width: 170px;
            max-width: 38vw;
            height: auto;
            opacity: 0.96;
            object-fit: contain;
            mix-blend-mode: normal;
            filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.18));
            pointer-events: none;
        }
        @media (max-width: 640px) {
            .brand-logo {
                width: 140px;
                max-width: 34vw;
            }
        }
        @media (max-height: 640px) {
            .coord-chip {
                top: calc(var(--fab-from-top) + var(--fab-size) + 6px);
                max-width: 148px;
                padding: 6px 9px;
                font-size: 9px;
            }
        }
        .scrim {
            position: fixed;
            inset: 0;
            z-index: 90;
            background: rgba(0, 0, 0, 0.22);
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.22s ease;
        }
        .scrim.open {
            opacity: 1;
            pointer-events: auto;
        }
        .sheet {
            position: fixed;
            z-index: 95;
            left: 0;
            right: 0;
            bottom: 0;
            max-height: min(92dvh, calc(100dvh - var(--safe-t) - 8px));
            padding: 12px 18px calc(20px + var(--safe-b));
            border-radius: var(--radius-sheet-top) var(--radius-sheet-top) 0 0;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
            background: linear-gradient(180deg, rgba(12, 16, 28, 0.86), rgba(6, 10, 18, 0.92));
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28);
            transform: translateY(108%);
            transition: transform 0.32s var(--ease-spring);
            overflow: auto;
            -webkit-overflow-scrolling: touch;
            pointer-events: none;
        }
        .sheet.open {
            transform: translateY(0);
            pointer-events: auto;
        }
        .grab {
            width: 40px;
            height: 4px;
            border-radius: 99px;
            margin: 0 auto 12px;
            background: rgba(148, 163, 184, 0.38);
            touch-action: none;
        }
        .sheet h2 { margin: 0; }
        .sheet-title {
            margin: 0 0 12px;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--muted);
        }
        #sheet-map.sheet {
            padding: 14px 18px calc(22px + var(--safe-b));
        }
        #sheet-map .sheet-wrap {
            padding: 8px 4px 12px;
        }
        #sheet-map .grab {
            margin-bottom: 14px;
        }
        #sheet-map .close-x {
            top: 14px;
            right: 14px;
        }
        .basemap-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 22px;
        }
        .map-card {
            position: relative;
            display: block;
            width: 100%;
            min-height: 158px;
            padding: 0;
            border: 1px solid rgba(255, 255, 255, 0.055);
            border-radius: 22px;
            overflow: hidden;
            cursor: pointer;
            text-align: left;
            background: rgba(8, 12, 22, 0.35);
            box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
            -webkit-tap-highlight-color: transparent;
        }
        .map-card:active {
            transform: scale(0.985);
        }
        .map-card-bg {
            position: absolute;
            inset: 0;
            background-position: 50% 32%;
            background-size: 220% 220%;
            opacity: 1;
            transition: transform 0.35s ease, opacity 0.2s ease;
        }
        .map-card:active .map-card-bg {
            transform: scale(1.04);
        }
        .map-card-osm {
            background-image: linear-gradient(155deg, #bfe8c2 0%, #8bc98f 28%, #7eb6df 72%, #5a9fd4 100%);
        }
        .map-card-topo {
            background-image: linear-gradient(165deg, #d4c4a8 0%, #9daf7a 35%, #6b8f71 70%, #4a6b58 100%);
        }
        .map-card-carto-l {
            background-image: linear-gradient(145deg, #e8f4fc 0%, #b8d4f0 40%, #7eb3e8 100%);
        }
        .map-card-carto-d {
            background-image: linear-gradient(155deg, #1a2332 0%, #243044 45%, #0f141f 100%);
        }
        .map-card-shade {
            position: absolute;
            inset: 0;
            background: linear-gradient(200deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.45) 55%, rgba(0, 0, 0, 0.65) 100%);
            pointer-events: none;
        }
        .map-card-label {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 2;
            padding: 16px 16px 14px;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            color: #f8fafc;
            text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
        }
        .map-card-carto-l .map-card-label {
            color: #0f172a;
            text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
        }
        .tile-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
        }
        .tile {
            min-height: 52px;
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.055);
            background: rgba(14, 20, 34, 0.48);
            color: var(--text);
            padding: 12px 10px;
            text-align: center;
            font-weight: 700;
            font-size: 12px;
            letter-spacing: 0.02em;
        }
        .tile:active { transform: scale(0.99); }
        /** 2×3 gyors alaptérkép a bal felső krómban — utolsó cella: sheet (DTM / WMS). */
        .fab-map-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px;
            width: calc(var(--fab-size) * 2 + 8px);
        }
        .fab-map-grid .tile {
            margin: 0;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
        }
        .tile--peek {
            min-height: 44px;
            padding: 8px 6px;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            line-height: 1.15;
        }
        .tile--peek-more {
            font-size: 9px;
            letter-spacing: 0.04em;
        }
        .close-x {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 38px;
            height: 38px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(14, 18, 30, 0.55);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            color: var(--text);
            font-size: 20px;
            line-height: 1;
            box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
            transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out);
        }
        .close-x:active {
            transform: scale(0.94);
        }
        .sheet-wrap { position: relative; padding-top: 4px; }
        .wizard { display: grid; gap: 10px; }
        .step-tabs {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }
        .step-tabs button {
            flex: 1 1 auto;
            min-width: 0;
            padding: 8px;
            border-radius: 11px;
            border: 1px solid rgba(255, 255, 255, 0.06);
            background: rgba(14, 20, 34, 0.5);
            color: var(--text);
            font-size: 10px;
            font-weight: 700;
        }
        .step-tabs button.on {
            border-color: rgba(56, 189, 248, 0.55);
            background: rgba(37, 99, 235, 0.35);
        }
        input.field, select.field, textarea.field {
            width: 100%;
            min-height: 44px;
            border-radius: 11px;
            border: 1px solid var(--line);
            background: rgba(6, 10, 20, 0.55);
            color: var(--text);
            padding: 8px 10px;
            font-size: 13px;
        }
        textarea.field { min-height: 72px; resize: vertical; }
        .btn-primary {
            width: 100%;
            min-height: 46px;
            border: 0;
            border-radius: 14px;
            font-weight: 700;
            font-size: 12px;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: #fff;
            background: linear-gradient(180deg, rgba(56, 189, 248, 0.95), rgba(37, 99, 235, 0.98));
            box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
        }
        #knm-toast {
            position: fixed;
            z-index: 120;
            left: 50%;
            right: auto;
            top: auto;
            bottom: calc(var(--fab-from-bottom) + var(--fab-size) + 14px);
            transform: translateX(-50%) translateY(calc(100% + 24px));
            max-width: 260px;
            width: min(260px, calc(100% - 32px));
            padding: 8px 12px;
            border-radius: 12px;
            background: rgba(10, 14, 24, 0.88);
            border: 1px solid rgba(255, 255, 255, 0.06);
            color: var(--text);
            font-size: 11px;
            font-weight: 600;
            line-height: 1.35;
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            pointer-events: none;
            text-align: center;
            transition: transform 0.3s var(--ease-spring);
        }
        #knm-toast.show {
            transform: translateX(-50%) translateY(0);
        }
        @media (prefers-reduced-motion: reduce) {
            .sheet,
            .fab,
            .map-card,
            .map-card-bg,
            #knm-toast,
            .scrim {
                transition-duration: 0.05s !important;
            }
        }

        /*
         * Réteg panel (iframe): a teljes chrome legyen átengedő, kivéve a kis FAB / chip / logo sávok,
         * hogy a motor oldalsávja kapja az érintést. NE emeljük az iframe-et a chrome fölé (z-index 300),
         * mert akkor a FAB-ok a motor alá kerülnek és nem zárható / nem használható a shell.
         */
        body.knm-engine-overlay-focus #knm-chrome {
            pointer-events: none !important;
        }
        body.knm-engine-overlay-focus #knm-chrome .fab-stack,
        body.knm-engine-overlay-focus #knm-chrome .coord-chip,
        body.knm-engine-overlay-focus #knm-chrome .brand-wrap {
            pointer-events: auto !important;
        }
