/* === Tooltip du chart + clavier virtuel (composant partagé) === */
        /* --- 7b. SVG CHART TOOLTIP --- */
        .chart-tooltip {
            position: absolute;
            pointer-events: none;
            background: #f8f9fd;
            color: #0f172a;
            border: 1px solid rgba(0, 0, 0, 0.08);
            border-radius: 0.75rem;
            padding: 0.6rem 0.85rem;
            font-size: 0.75rem;
            font-family: inherit;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.02);
            opacity: 0;
            transform: translate(-50%, -100%) translateY(-10px) scale(0.95);
            transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 9999;
            white-space: nowrap;
        }
        [data-theme="dark"] .chart-tooltip {
            background: #192236;
            color: #f8fafc;
            border: 1px solid rgba(255, 255, 255, 0.08);
            box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
        }
        .chart-tooltip.is-visible {
            opacity: 1;
            transform: translate(-50%, -100%) translateY(-10px) scale(1);
        }
        .chart-tooltip-cat {
            font-weight: 800;
            margin-right: 0.4rem;
        }
        .chart-tooltip-count {
            font-weight: 700;
            color: var(--accent);
        }
        [data-theme="dark"] .chart-tooltip-count {
            color: #60a5fa;
        }
        .chart-tooltip-ratio {
            color: var(--text-secondary);
            font-size: 0.65rem;
            margin-left: 0.25rem;
        }

        .shortcut-card:hover {
            box-shadow: var(--shadow-md);
            transform: translateY(-2px);
            transition: box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .card-header {
            margin-bottom: 0.7rem;
        }

        .card-title {
            margin: 0;
            font-size: 0.95rem;
            font-weight: 750;
            color: var(--text-primary);
            line-height: 1.3;
            flex: 1 1 auto;
            min-width: 0;
        }

        .card-badge {
            font-size: 0.52rem;
            font-weight: 800;
            padding: 0.25rem 0.5rem;
            border-radius: 0.45rem;
            color: #fff;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            white-space: normal;
            overflow-wrap: anywhere;
            max-width: 100%;
            box-sizing: border-box;
        }

        .card-badges {
            display: flex;
            flex-wrap: wrap;
            align-items: flex-start;
            gap: 0.25rem;
            min-width: 0;
        }

        .card-category {
            margin: 0.65rem 0 0.8rem;
        }

        .card-identity {
            display: flex;
            align-items: center;
            gap: 0.4rem;
            margin-left: auto;
            min-width: 0;
        }

        .card-footer .card-keyboard {
            display: grid;
            place-items: center;
            width: 36px;
            height: 36px;
            padding: 0;
            border: 1px solid var(--border-color);
            border-radius: 0.65rem;
            color: var(--text-secondary);
        }

        .card-actions {
            display: flex;
            gap: 0.35rem;
            align-items: center;
        }

        .card-act {
            border: none;
            background: transparent;
            cursor: pointer;
            font-size: 1rem;
            line-height: 1;
            padding: 0.15rem 0.25rem;
            border-radius: 0.4rem;
            color: var(--text-tertiary);
            transition: transform 0.12s ease, color 0.12s ease, background 0.12s ease;
        }

        .card-act:hover {
            background: var(--accent-light);
            transform: scale(1.12);
        }

        /* Icône clavier (dans le pied de carte) — agrandie */
        .kbd-btn {
            font-size: 1.35rem;
            padding: 0.2rem 0.35rem;
        }

        /* Le favori termine le pied de carte, après l'identifiant. */
        .fav-btn.card-fav-bottom {
            display: grid;
            place-items: center;
            width: 36px;
            height: 36px;
            font-size: 1.35rem;
            line-height: 1;
            padding: 0;
            color: var(--text-tertiary);
            flex-shrink: 0;
        }

        .fav-btn.card-fav-bottom:hover {
            color: #f5a623;
        }

        .fav-btn.is-fav {
            color: #f5a623;
        }

        /* Zone des touches cliquable → ouvre le clavier visuel */
        .card-keys-zone.kz-clickable {
            cursor: pointer;
        }

        .card-keys-zone.kz-clickable:hover {
            border-color: var(--accent);
        }

        .card-keys-zone.kz-clickable:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        .fav-filter-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            width: 100%;
            justify-content: flex-start;
            padding: 0.5rem 0.75rem;
            margin-bottom: 0.25rem;
            border: 1px solid var(--border-color);
            border-radius: 0.6rem;
            background: var(--bg-card);
            color: var(--text-primary);
            font-weight: 700;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .fav-filter-btn:hover {
            border-color: #f5a623;
        }

        .fav-filter-btn.active {
            background: #f5a62320;
            border-color: #f5a623;
            color: #f5a623;
        }

        /* ---- Clavier virtuel partagé ---- */
        .modal-card.keyboard-modal {
            width: min(96vw, 1260px);
            max-width: 1260px;
            max-height: 92vh;
            overflow-y: auto;
        }
        #keyboardModal,
        #detectorModal {
            background:
                radial-gradient(circle at 14% 14%, rgba(239, 128, 182, 0.15), transparent 42%),
                radial-gradient(circle at 87% 84%, rgba(111, 157, 241, 0.18), transparent 46%),
                rgba(20, 31, 55, 0.46);
        }
        #keyboardModal .keyboard-modal,
        #detectorModal .detector-modal {
            /* Une seule couche de flou par dialogue : évite les textes du fond
               lisibles à travers le verre, sans filtre sur chaque touche. */
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            background: linear-gradient(180deg,
                rgba(255, 255, 255, 0.985) 0%,
                rgba(250, 252, 255, 0.97) 26%,
                rgba(240, 247, 255, 0.73) 55%,
                rgba(232, 241, 254, 0.28) 100%);
            border-color: rgba(255, 255, 255, 0.72);
            box-shadow: 0 26px 72px rgba(17, 33, 61, 0.23),
                inset 0 1px 0 rgba(255, 255, 255, 0.85);
        }
        #detectorModal .detector-modal {
            background: linear-gradient(180deg,
                rgba(255, 255, 255, 0.985),
                rgba(240, 247, 255, 0.92));
        }
        [data-theme="dark"] #keyboardModal,
        [data-theme="dark"] #detectorModal {
            background:
                radial-gradient(circle at 15% 12%, rgba(158, 78, 129, 0.18), transparent 44%),
                radial-gradient(circle at 84% 86%, rgba(57, 111, 201, 0.19), transparent 48%),
                rgba(3, 9, 22, 0.68);
        }
        [data-theme="dark"] #keyboardModal .keyboard-modal,
        [data-theme="dark"] #detectorModal .detector-modal {
            background: linear-gradient(180deg,
                rgba(25, 37, 58, 0.98) 0%,
                rgba(24, 38, 60, 0.95) 28%,
                rgba(25, 43, 69, 0.76) 56%,
                rgba(31, 52, 82, 0.42) 100%);
            border-color: rgba(196, 218, 248, 0.24);
            box-shadow: 0 28px 76px rgba(0, 0, 0, 0.46),
                inset 0 1px 0 rgba(255, 255, 255, 0.13);
        }
        [data-theme="dark"] #detectorModal .detector-modal {
            background: linear-gradient(180deg,
                rgba(25, 37, 58, 0.98),
                rgba(25, 43, 69, 0.90));
        }
        #keyboardModal .keyboard-modal {
            transform: translateY(22px);
            transform-origin: center center;
            opacity: 0;
            transition: transform 160ms cubic-bezier(.4,0,1,1), opacity 160ms ease;
        }
        #keyboardModal.is-visible .keyboard-modal {
            transform: translateY(0);
            opacity: 1;
            transition: transform 280ms cubic-bezier(.16,1,.3,1), opacity 240ms ease;
        }
        #keyboardModal.kb-keyboard-entering #keyboardModalBody .kb-shell {
            opacity: 0;
            transition: opacity 180ms ease;
        }
        #keyboardModal.kb-keyboard-ready #keyboardModalBody .kb-shell {
            opacity: 1;
            transition: opacity 210ms ease 90ms;
        }
        #keyboardModal.kb-motion-off .keyboard-modal,
        #keyboardModal.kb-motion-off.is-visible .keyboard-modal {
            transform: none;
            opacity: 1;
            transition: none;
        }
        #keyboardModal.kb-motion-off #keyboardModalBody .kb-shell {
            opacity: 1;
            transition: none;
        }
        @media (prefers-reduced-motion: reduce) {
            #keyboardModal .keyboard-modal,
            #keyboardModal.is-visible .keyboard-modal {
                transform: none;
                opacity: 1;
                transition: none;
            }
            #keyboardModal.kb-keyboard-entering #keyboardModalBody .kb-shell {
                opacity: 1;
                transition: none;
            }
        }

        .kb-info {
            display: flex;
            flex-direction: column;
            gap: 0.15rem;
            margin-bottom: 0.65rem;
            text-align: left;
        }

        .kb-combo {
            color: var(--text-secondary);
            font-size: 0.85rem;
        }

        .kb-local-description {
            margin: 0 0 .65rem;
            color: var(--text-secondary);
            font-size: .85rem;
            line-height: 1.5;
            overflow-wrap: anywhere;
        }

        .kb-config-group {
            display: flex;
            gap: 2px;
            padding: 3px;
            border: 1px solid color-mix(in srgb, var(--kb-key-border) 72%, transparent);
            border-radius: 10px;
            background: rgba(127, 127, 127, 0.08);
        }

        .kb-config-btn,
        .kb-numpad-toggle {
            border: 0;
            font: inherit;
            color: var(--text-secondary);
            cursor: pointer;
        }

        .kb-config-btn {
            min-height: 28px;
            flex: 1 1 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.35rem;
            padding: 0.28rem 0.55rem;
            border-radius: 7px;
            background: transparent;
            font-size: 0.72rem;
            font-weight: 800;
            transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
        }

        .kb-config-btn .kb-os-icon { width: 0.9rem; height: 0.9rem; }
        .kb-config-btn:hover:not(:disabled) { color: var(--text-primary); }
        .kb-config-btn.is-active {
            background: var(--accent);
            color: #fff;
            box-shadow: 0 2px 8px var(--accent-light);
        }
        .kb-config-btn:disabled { opacity: 0.36; cursor: not-allowed; }

        .kb-shell {
            --kb-unit: 46px;
            --kb-key-h: 49px;
            --kb-function-h: 43px;
            --kb-gap: 8px;
            --kb-radius: 8px;
            --kb-main-w: calc(var(--kb-unit) * 16.4 + var(--kb-gap) * 15 + 32px);
            --kb-panel-bg: linear-gradient(145deg, rgba(255, 255, 255, 0.65), rgba(220, 235, 255, 0.36));
            --kb-panel-border: rgba(255, 255, 255, 0.9);
            --kb-panel-shadow: 0 9px 22px rgba(27, 49, 81, 0.18),
                0 26px 48px rgba(32, 68, 105, 0.12),
                inset 0 1px 1px rgba(255, 255, 255, 0.95),
                inset 0 -1px 0 rgba(117, 151, 198, 0.12);
            --kb-key-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(243, 248, 255, 0.84) 100%);
            --kb-key-border: #c3d1e0;
            --kb-key-text: #071641;
            --kb-key-shadow: #b8c6d5;
            --kb-key-drop: rgba(24, 54, 85, 0.16);
            width: 100%;
            color: var(--kb-key-text);
        }

        [data-theme="dark"] .kb-shell {
            --kb-panel-bg: linear-gradient(145deg, rgba(79, 108, 153, 0.42), rgba(14, 31, 56, 0.56));
            --kb-panel-border: rgba(194, 219, 250, 0.35);
            --kb-panel-shadow: 0 9px 24px rgba(0, 0, 0, 0.34),
                0 26px 54px rgba(0, 0, 0, 0.3),
                inset 0 1px 1px rgba(255, 255, 255, 0.18),
                inset 0 -1px 0 rgba(3, 10, 25, 0.35);
            --kb-key-bg: linear-gradient(180deg, rgba(53, 72, 101, 0.9) 0%, rgba(27, 46, 73, 0.84) 100%);
            --kb-key-border: #536c88;
            --kb-key-text: #f8fafc;
            --kb-key-shadow: #0d1628;
            --kb-key-drop: rgba(0, 0, 0, 0.35);
        }

        .kb-shell.kb-profile-mobile {
            --kb-unit: 18px;
            --kb-key-h: 38px;
            --kb-function-h: 34px;
            --kb-gap: 3px;
            --kb-radius: 5px;
            --kb-main-w: 360px;
        }

        .kb-controlbar {
            position: relative;
            z-index: 15;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            height: 24px;
            flex: 0 0 24px;
        }

        .kb-controlbar-spacer { flex: 1 1 auto; }
        .kb-controlbar-actions {
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .kb-profile-badge {
            color: var(--text-secondary);
            font-size: 0.61rem;
            font-weight: 750;
            white-space: nowrap;
            pointer-events: none;
        }

        .kb-numpad-toggle {
            display: inline-flex;
            align-items: center;
            gap: 0.38rem;
            min-height: 24px;
            padding: 0.18rem 0.45rem 0.18rem 0.55rem;
            border: 0;
            border-radius: 999px;
            background: transparent;
            font-size: 0.64rem;
            font-weight: 750;
            transition: color 0.15s ease;
        }

        .kb-numpad-toggle:focus-visible { outline: none; }
        .kb-numpad-toggle:focus-visible .kb-numpad-label { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
        .kb-numpad-toggle:disabled { cursor: default; opacity: 0.74; }
        .kb-numpad-label { opacity: 0.82; }

        .kb-switch {
            width: 24px;
            height: 14px;
            display: inline-flex;
            align-items: center;
            padding: 2px;
            border-radius: 999px;
            background: rgba(100, 116, 139, 0.35);
            transition: background-color 0.16s ease;
        }

        .kb-switch > span {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #fff;
            box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
            transform: translateX(0);
            transition: transform 0.16s ease;
        }

        .kb-numpad-toggle[aria-pressed="true"] .kb-switch { background: var(--accent); }
        .kb-numpad-toggle[aria-pressed="true"] .kb-switch > span { transform: translateX(10px); }

        .kb-settings { position: relative; }
        .kb-settings-toggle {
            width: 25px;
            height: 25px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border: 0;
            border-radius: 8px;
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            transition: color 0.15s ease;
        }
        .kb-settings-toggle:hover,
        .kb-settings.is-open .kb-settings-toggle { color: var(--accent); }
        .kb-settings-toggle:focus-visible { outline: none; color: var(--accent); }
        .kb-settings-toggle:focus-visible .kb-settings-icon { filter: drop-shadow(0 0 4px var(--accent)); }
        .kb-settings-icon { width: 17px; height: 17px; transform-origin: center; }
        .kb-settings-panel {
            position: absolute;
            top: auto;
            bottom: calc(100% + 7px);
            right: 0;
            z-index: 30;
            width: 244px;
            display: none;
            gap: 5px;
            padding: 10px;
            max-height: calc(100vh - 20px);
            overflow-y: auto;
            border: 1px solid rgba(255, 255, 255, 0.74);
            border-radius: 13px;
            background: linear-gradient(145deg, #ffffff, #e1eeff);
            box-shadow: 0 16px 34px rgba(15, 23, 42, 0.20), inset 0 1px rgba(255,255,255,.82), inset 0 -1px rgba(255,255,255,.26);
            backdrop-filter: blur(16px) saturate(140%);
            -webkit-backdrop-filter: blur(16px) saturate(140%);
        }
        [data-theme="dark"] .kb-settings-panel {
            background: linear-gradient(145deg, #2e425e, #0f1f37);
            border-color: rgba(185, 208, 238, .32);
            box-shadow: 0 16px 34px rgba(0,0,0,.38), inset 0 1px rgba(255,255,255,.19), inset 0 -1px rgba(255,255,255,.05);
        }
        .kb-settings.is-open .kb-settings-panel { display: grid; }
        .kb-settings-title {
            margin: 2px 2px 0;
            color: var(--text-secondary);
            font-size: 0.58rem;
            font-weight: 850;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }

        .kb-pref-row {
            display: grid;
            gap: 4px;
            padding: 6px 3px 2px;
            border-top: 1px solid color-mix(in srgb, var(--kb-key-border) 55%, transparent);
        }
        .kb-pref-label {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            color: var(--text-primary);
            font-size: 0.69rem;
            font-weight: 700;
        }
        .kb-pref-value { color: var(--text-secondary); font-weight: 600; }
        .kb-pref-row input[type="range"] {
            width: 100%;
            margin: 2px 0 5px;
            accent-color: var(--accent);
            cursor: pointer;
        }
        .kb-pref-row input[type="range"]:disabled { cursor: not-allowed; opacity: .5; }
        .kb-feedback-control { position: relative; padding-top: 27px; }
        .kb-feedback-control input[type="range"] { display: block; margin-bottom: 1px; }
        .kb-feedback-bubble {
            position: absolute;
            top: 0;
            left: clamp(22px, var(--kb-feedback-position, 0%), calc(100% - 22px));
            z-index: 1;
            min-width: 43px;
            padding: 4px 9px;
            border: 1px solid rgba(255, 255, 255, .36);
            border-radius: 999px;
            background: var(--accent);
            background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 78%, white), var(--accent));
            box-shadow: 0 7px 17px rgba(24, 35, 62, .22), inset 0 1px rgba(255, 255, 255, .22);
            color: #fff;
            font-size: .65rem;
            font-weight: 800;
            font-variant-numeric: tabular-nums;
            line-height: 1.25;
            text-align: center;
            white-space: nowrap;
            pointer-events: none;
            opacity: 0;
            filter: blur(3px);
            transform: translate(-50%, 7px) scale(.88);
            transition: left .16s cubic-bezier(.2, .8, .2, 1), opacity .18s ease, filter .22s ease, transform .26s cubic-bezier(.16, 1, .3, 1);
        }
        .kb-feedback-bubble::after {
            content: '';
            position: absolute;
            top: calc(100% - 1px);
            left: 50%;
            border: 5px solid transparent;
            border-top-color: var(--accent);
            transform: translateX(-50%);
        }
        .kb-feedback-bubble.is-visible { opacity: 1; filter: blur(0); transform: translate(-50%, 0) scale(1); }
        .kb-pref-unavailable { color: var(--text-secondary); font-size: .6rem; line-height: 1.2; }
        .kb-pref-row input[type="range"]:focus-visible,
        .kb-pref-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
        .kb-pref-switch { display: flex; align-items: center; justify-content: space-between; }
        .kb-pref-toggle {
            min-width: 68px;
            min-height: 29px;
            padding: 4px 8px;
            border: 1px solid var(--kb-key-border);
            border-radius: 7px;
            background: rgba(127,127,127,.08);
            color: var(--text-secondary);
            font: inherit;
            font-size: .68rem;
            font-weight: 750;
            cursor: pointer;
        }
        .kb-pref-toggle[aria-pressed="true"] {
            color: #fff;
            border-color: var(--accent);
            background: var(--accent);
        }

        .kb-profile-mobile .kb-numpad,
        .kb-profile-mobile .kb-numpad-toggle { display: none !important; }

        /* Fenêtre de recadrage : la hauteur suit l'échelle calculée par JS. */
        .kb-viewport {
            position: relative;
            width: 100%;
            /* Le pavé sortant ne doit pas étendre la zone défilable du dialogue.
               Clip horizontal seulement : les ombres restent libres en hauteur. */
            overflow-x: clip;
            overflow-y: visible;
        }

        .kb-board {
            position: absolute;
            top: 0;
            left: 50%;
            width: max-content;
            display: flex;
            align-items: stretch;
            gap: 16px;
            transform: translateX(-50%);
            transform-origin: top center;
        }

        .kb-main,
        .kb-numpad {
            border: 1px solid var(--kb-panel-border);
            border-radius: 22px;
            background: var(--kb-panel-bg);
            box-shadow: var(--kb-panel-shadow);
            backdrop-filter: blur(26px) saturate(150%);
            -webkit-backdrop-filter: blur(26px) saturate(150%);
        }

        .kb-main {
            width: var(--kb-main-w);
            position: relative;
            display: flex;
            flex-direction: column;
            gap: var(--kb-gap);
            padding: 16px;
        }

        /* Un seul corps découpé porte la bosse, la dalle et son ombre.
           Les touches et panneaux restent hors du découpage. */
        .kb-profile-desktop .kb-main {
            --kb-chassis-shape: shape(from 0 24px,
                line to 0 22px,
                curve to 22px 0 with 0 10px / 10px 0,
                line to 218px 0,
                curve to 270px 24px with 244px 0 / 244px 24px,
                line to calc(100% - 22px) 24px,
                curve to 100% 46px with calc(100% - 10px) 24px / 100% 34px,
                line to 100% calc(100% - 22px),
                curve to calc(100% - 22px) 100% with 100% calc(100% - 10px) / calc(100% - 10px) 100%,
                line to 22px 100%,
                curve to 0 calc(100% - 22px) with 10px 100% / 0 calc(100% - 10px),
                close);
            border-color: transparent;
            background: transparent;
            box-shadow: none;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }
        .kb-chassis {
            position: absolute;
            inset: 0;
            z-index: -1;
            pointer-events: none;
            filter: drop-shadow(0 0 1px var(--kb-chassis-rim))
                drop-shadow(0 10px 17px var(--kb-chassis-shadow-near))
                drop-shadow(0 16px 24px var(--kb-chassis-shadow-far));
        }
        .kb-chassis::before {
            content: '';
            position: absolute;
            inset: 0;
            clip-path: var(--kb-chassis-shape);
            background: var(--kb-chassis-bg);
        }
        .kb-profile-desktop .kb-chassis { inset: -1px; }
        .kb-profile-desktop,
        .kb-profile-mobile {
            --kb-chassis-bg: linear-gradient(155deg, #eef5ff 0%, #dfeafa 56%, #d4e2f5 100%);
            --kb-chassis-rim: rgba(106, 128, 160, .42);
            --kb-chassis-shadow-near: rgba(27, 49, 81, .17);
            --kb-chassis-shadow-far: rgba(32, 68, 105, .10);
        }
        .kb-profile-desktop .kb-main,
        .kb-profile-mobile .kb-main { isolation: isolate; }
        [data-theme="dark"] .kb-profile-desktop,
        [data-theme="dark"] .kb-profile-mobile {
            --kb-chassis-bg: linear-gradient(155deg, #2b4260 0%, #263b58 56%, #1d304a 100%);
            --kb-chassis-rim: rgba(225, 234, 247, .34);
            --kb-chassis-shadow-near: rgba(0, 0, 0, .35);
            --kb-chassis-shadow-far: rgba(0, 0, 0, .22);
        }
        .kb-profile-desktop .kb-controlbar {
            justify-content: flex-start;
            top: -4px;
        }

        .kb-profile-mobile .kb-main {
            --kb-chassis-shape: shape(from 0 38px,
                curve to 12px 26px with 0 31.4px / 5.4px 26px,
                line to calc(100% - 137px) 26px,
                curve to calc(100% - 95px) 0 with calc(100% - 119px) 26px / calc(100% - 115px) 0,
                line to calc(100% - 12px) 0,
                curve to 100% 12px with calc(100% - 5px) 0 / 100% 5px,
                line to 100% calc(100% - 12px),
                curve to calc(100% - 12px) 100% with 100% calc(100% - 5px) / calc(100% - 5px) 100%,
                line to 12px 100%,
                curve to 0 calc(100% - 12px) with 5px 100% / 0 calc(100% - 5px),
                close);
            width: var(--kb-main-w);
            padding: 33px 7px 7px;
            border: 0;
            border-radius: 0;
            isolation: isolate;
            background: transparent;
            box-shadow: none;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }
        @supports not (clip-path: shape(from 0 0, line to 1px 1px, close)) {
            .kb-profile-desktop .kb-main {
                --kb-chassis-shape: polygon(
                    0 24px, 0 22px, 2px 13px, 8px 4px, 16px 1px, 22px 0,
                    218px 0, 231px 2px, 242px 11px, 252px 21px, 270px 24px,
                    calc(100% - 22px) 24px, calc(100% - 12px) 27px,
                    calc(100% - 3px) 36px, 100% 46px,
                    100% calc(100% - 22px), calc(100% - 3px) calc(100% - 12px),
                    calc(100% - 12px) calc(100% - 3px), calc(100% - 22px) 100%,
                    22px 100%, 12px calc(100% - 3px), 3px calc(100% - 12px),
                    0 calc(100% - 22px));
            }
            .kb-profile-mobile .kb-main {
                --kb-chassis-shape: polygon(
                    0 38px, 1px 33px, 3px 29px, 7px 27px, 12px 26px,
                    calc(100% - 137px) 26px, calc(100% - 129px) 25px,
                    calc(100% - 123px) 22px, calc(100% - 117px) 17px,
                    calc(100% - 112px) 11px, calc(100% - 107px) 5px,
                    calc(100% - 101px) 1px, calc(100% - 95px) 0,
                    calc(100% - 12px) 0, calc(100% - 7px) 1px,
                    calc(100% - 3px) 4px, 100% 12px,
                    100% calc(100% - 12px), calc(100% - 1px) calc(100% - 7px),
                    calc(100% - 4px) calc(100% - 3px), calc(100% - 12px) 100%,
                    12px 100%, 4px calc(100% - 3px), 1px calc(100% - 7px),
                    0 calc(100% - 12px)
                );
            }
        }

        /* Le profil mobile a une seule dalle : aucun coussin invisible ne doit
           s'ajouter autour du châssis. L'ancienne règle responsive générique
           (.kb-board { padding: 5px }) réduisait le clavier après calcul de
           l'échelle et faussait sa largeur apparente. */
        .kb-profile-mobile .kb-board {
            padding: 0;
            gap: 0;
        }

        .kb-profile-mobile .kb-controlbar {
            height: 22px;
            flex-basis: 22px;
        }

        .kb-profile-mobile .kb-settings-toggle {
            width: 22px;
            height: 22px;
            border-radius: 7px;
        }

        .kb-profile-mobile .kb-settings-icon { width: 14px; height: 14px; }

        .kb-row {
            width: 100%;
            min-width: 0;
            display: flex;
            align-items: stretch;
            justify-content: space-between;
            gap: var(--kb-gap);
            flex-wrap: nowrap;
        }
        .kb-profile-desktop .kb-row { justify-content: flex-start; }
        .kb-profile-desktop .kb-row > .kb-key { flex-grow: 1; }
        .kb-profile-desktop .kb-function-row { margin-top: -4px; margin-bottom: 4px; }
        .kb-profile-desktop .kb-bottom-row > .kb-key { flex-grow: 0; }
        .kb-profile-desktop .kb-bottom-row > [data-kbid="space"] { flex: 1 1 0; width: auto; }
        .kb-profile-desktop .kb-tab-key { gap: 6px; }
        .kb-profile-desktop .kb-tab-symbol { width: 19px; height: 19px; flex: 0 0 19px; }
        .kb-profile-desktop .kb-number-row .kb-legend-shift { font-size: 1.02em; font-weight: 800; }
        .kb-profile-desktop .kb-number-row .kb-legend-main { font-size: 1.12em; }
        .kb-profile-desktop .kb-key[data-kbid^="L"] .kb-legend-main {
            font-size: 1.3125em;
            line-height: 1;
        }
        /* En AZERTY Windows, Verr Maj fait passer les chiffres au premier
           niveau. Leur doublon masqué ne doit pas les décaler vers le bas. */
        .kb-profile-desktop[data-os="win"][data-layout="fr"][data-caps-lock="true"].is-shift-layer
            .kb-number-row .kb-key[data-kbid^="d"] .kb-legend-shift { display: none; }
        .kb-profile-desktop[data-os="win"][data-layout="fr"][data-caps-lock="true"].is-shift-layer
            .kb-number-row .kb-key[data-kbid^="d"] .kb-legend-main {
            line-height: 1;
        }
        .kb-profile-desktop .kb-number-row .kb-legend-alt {
            right: 2px;
            bottom: 2px;
            font-size: .78em;
            opacity: .86;
        }
        .kb-profile-desktop [data-kbid="menu"] .kb-menu-icon { width: 1.45rem; height: 1.45rem; }
        .kb-profile-desktop [data-kbid="backspace"] { gap: 4px; padding-inline: 4px; }
        .kb-profile-desktop [data-kbid="backspace"] .kb-key-word { font-size: .94em; }
        .kb-profile-desktop .kb-backspace-arrow {
            width: 16px; height: 16px; flex-basis: 16px;
        }

        .kb-gap { flex: 0 0 calc(var(--kb-gap) * 1.35); }
        .kb-profile-mobile .kb-gap { display: none; }

        /* Les touches de fonction sont volontairement un peu plus basses :
           leur silhouette reste lisible tout en se distinguant du bloc alphanumérique. */
        .kb-function-row { align-items: flex-start; }
        .kb-function-row .kb-key {
            height: var(--kb-function-h);
            font-size: 0.75rem;
        }

        .kb-profile-mobile .kb-function-row .kb-key {
            font-size: 0.5rem;
            line-height: 0.96;
            letter-spacing: -0.02em;
        }

        .kb-profile-mobile .kb-function-row .kb-key.kb-mod { font-size: 0.43rem; }
        .kb-profile-mobile .kb-function-row .kb-multiline {
            max-width: 100%;
            font-size: 0.39rem;
            line-height: 0.94;
            white-space: normal;
        }

        .kb-alpha-pair {
            width: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr) calc(var(--kb-unit) * 1.65);
            gap: var(--kb-gap);
        }

        .kb-alpha-lines {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: var(--kb-gap);
        }

        /* La rangée centrale réserve une touche entière à la branche basse de
           l'Entrée ISO. Aucune touche n'est recouverte par la forme en L. */
        .kb-home-row { padding-right: calc(var(--kb-unit) + var(--kb-gap)); }

        .kb-key {
            appearance: none;
            -webkit-appearance: none;
            flex: 0 0 calc(var(--kb-unit) * var(--kb-span, 1));
            width: calc(var(--kb-unit) * var(--kb-span, 1));
            min-width: 0;
            height: var(--kb-key-h);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.25rem;
            padding: 0 5px;
            border: 1px solid var(--kb-key-border);
            border-radius: var(--kb-radius);
            background: var(--kb-key-bg);
            color: var(--kb-key-text);
            box-shadow: 0 3px 0 var(--kb-key-shadow), 0 7px 10px var(--kb-key-drop), inset 0 1px 0 rgba(255, 255, 255, 0.46);
            font-family: inherit;
            font-size: 0.82rem;
            font-weight: 800;
            line-height: 1.02;
            white-space: nowrap;
            cursor: pointer;
            touch-action: none;
            -webkit-touch-callout: none;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
            -webkit-user-select: none;
            transform: translateY(0);
            transition: transform 90ms ease, box-shadow 90ms ease, border-color 120ms ease, color 120ms ease, background-color 120ms ease;
        }
        .kb-key[aria-hidden="true"] { cursor: default; }

        [data-theme="dark"] .kb-key { box-shadow: 0 3px 0 var(--kb-key-shadow), 0 8px 15px var(--kb-key-drop), inset 0 1px 0 rgba(255, 255, 255, 0.07); }

        @media (hover: hover) and (pointer: fine) {
            .kb-key:hover { border-color: color-mix(in srgb, var(--accent) 42%, var(--kb-key-border)); }
        }
        .kb-key:focus-visible,
        .kb-config-btn:focus-visible {
            outline: 3px solid var(--accent-light);
            outline-offset: 2px;
            border-color: var(--accent);
        }

        .kb-key:active,
        .kb-key.is-pressed {
            transition: none;
            transform: translateY(2px) scale(0.992);
            box-shadow: 0 1px 0 var(--kb-key-shadow), 0 2px 4px var(--kb-key-drop), inset 0 1px 0 rgba(255, 255, 255, 0.28);
        }


        .kb-key.kb-mod {
            color: var(--kb-key-text);
            font-size: 0.7rem;
        }

        .kb-legends {
            position: relative;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 1px;
        }

        .kb-legend-shift { font-size: 0.72em; opacity: 0.78; }
        .kb-legend-main { font-size: 1.05em; }
        .kb-legend-alt,
        .kb-legend-alt-shift {
            position: absolute;
            right: 1px;
            bottom: 1px;
            font-size: 0.59em;
            opacity: 0.72;
        }
        .kb-legend-alt-shift { display: none; }
        /* Le niveau sélectionné est déjà le symbole principal. Éviter de
           l'afficher deux fois sans déplacer les autres repères du desktop. */
        .kb-profile-desktop.is-shift-layer .kb-legend-shift,
        .kb-profile-desktop.is-alt-layer:not(.is-alt-shift-layer) .kb-legend-alt { visibility: hidden; }

        .kb-multiline { font-size: 0.68rem; line-height: 1.08; }
        .kb-key-icon { font-size: 1.15rem; }
        .kb-backspace-icon { display: none; }
        .kb-backspace-arrow { display: block; }
        .kb-mod-symbol { font-size: 1.08rem; }
        .kb-os-icon, .kb-menu-icon { width: 1.12rem; height: 1.12rem; flex: 0 0 auto; }
        .kb-globe { font-size: 0.95rem; }

        /* Le filtre est sur le parent : il suit la silhouette en L sans être
           coupé par le clip-path de la touche. */
        .kb-enter-wrap {
            position: relative;
            width: calc(var(--kb-unit) * 2.65 + var(--kb-gap));
            height: 100%;
            justify-self: end;
            margin-left: calc(0px - var(--kb-unit) - var(--kb-gap));
            pointer-events: none;
            filter:
                drop-shadow(0 0 1.3px var(--kb-key-border))
                drop-shadow(0 3px 0 var(--kb-key-shadow))
                drop-shadow(0 7px 10px var(--kb-key-drop));
            /* Changer le halo d'un seul coup évite une couleur intermédiaire
               lorsque la sélection quitte Entrée ; le travel reste sur la touche. */
            transition: none;
        }
        .kb-enter-wrap:has(> .kb-enter.is-lit) {
            filter:
                drop-shadow(0 0 0.8px var(--accent))
                drop-shadow(0 3px 0 color-mix(in srgb, var(--accent) 72%, #000))
                drop-shadow(0 8px 16px color-mix(in srgb, var(--accent) 24%, transparent));
        }
        .kb-enter-wrap:has(> .kb-enter:active),
        .kb-enter-wrap:has(> .kb-enter.is-pressed) {
            filter:
                drop-shadow(0 0 0.7px var(--kb-key-border))
                drop-shadow(0 1px 0 var(--kb-key-shadow))
                drop-shadow(0 2px 4px var(--kb-key-drop));
        }
        .kb-enter-wrap:has(> .kb-enter.is-lit:active),
        .kb-enter-wrap:has(> .kb-enter.is-lit.is-pressed) {
            filter:
                drop-shadow(0 0 0.8px var(--accent))
                drop-shadow(0 1px 0 color-mix(in srgb, var(--accent) 72%, #000))
                drop-shadow(0 2px 4px color-mix(in srgb, var(--accent) 22%, transparent));
        }
        .kb-enter-outline {
            position: absolute;
            inset: 0;
            z-index: 2;
            width: 100%;
            height: 100%;
            overflow: visible;
            pointer-events: none;
        }
        .kb-enter-outline path { fill: none; stroke: var(--kb-key-border); stroke-width: 1.5; }
        .kb-enter-wrap:has(> .kb-enter.is-lit) .kb-enter-outline path { stroke: var(--accent); }
        .kb-enter {
            position: relative;
            width: 100%;
            height: 100%;
            display: block;
            padding: 0;
            border: 0;
            border-radius: 0;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55);
            pointer-events: auto;
            clip-path: polygon(
                calc(var(--kb-unit) + var(--kb-gap)) 0,
                100% 0,
                100% 100%,
                0 100%,
                0 calc(50% + var(--kb-gap) / 2),
                calc(var(--kb-unit) + var(--kb-gap)) calc(50% + var(--kb-gap) / 2)
            );
            /* Le tracé arrondi reprend exactement les 130 × 106 px de la touche
               avant la mise à l'échelle globale du clavier. Le polygon ci-dessus
               reste un repli sûr pour les moteurs qui ne prennent pas path(). */
            clip-path: path("M 62 0 H 122 Q 130 0 130 8 V 98 Q 130 106 122 106 H 8 Q 0 106 0 98 V 65 Q 0 57 8 57 H 46 Q 54 57 54 49 V 8 Q 54 0 62 0 Z");
        }
        .kb-enter > .kb-enter-symbol {
            position: absolute;
            top: 15px;
            left: 92px;
            font-size: 2.2rem;
            line-height: 1;
            transform: translateX(-50%);
        }
        .kb-enter-label {
            position: absolute;
            bottom: 16px;
            left: 50%;
            width: calc(100% - 16px);
            text-align: center;
            line-height: 1;
            transform: translateX(-50%);
        }
        .kb-np-enter .kb-enter-symbol { font-size: 1.5rem; line-height: 0.75; }
        .kb-np-page-icon { width: 23px; height: 23px; display: block; }

        .kb-mobile-alpha-pair {
            grid-template-columns: minmax(0, 1fr) calc(var(--kb-unit) * 1.65);
        }

        .kb-mobile-enter {
            width: auto;
            height: 100%;
            flex-direction: column;
            gap: 0.38rem;
            /* La colonne conserve exactement ses 1,65 unités de référence.
               On récupère seulement l'espace intérieur qui rognait « Entrée »
               sur les petits écrans. */
            padding: 3px 1px;
        }

        .kb-mobile-enter-symbol {
            order: 1;
            font-size: 0.82rem;
            line-height: 0.9;
        }

        .kb-mobile-enter-label {
            order: 0;
            max-width: 100%;
            font-size: 0.5rem;
            line-height: 1;
        }

        .kb-profile-mobile .kb-mobile-lower-row .kb-shift-key {
            flex-direction: row;
        }

        .kb-bottom-row { align-items: stretch; }
        .kb-shell[data-os="mac"] .kb-bottom-row .kb-mod { flex-direction: column; gap: 1px; }

        .kb-lock-key { position: relative; }
        .kb-lock-label {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.3rem;
        }
        .kb-lock-led {
            position: absolute;
            top: 6px;
            right: 7px;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--kb-key-text);
            box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08);
            opacity: 1;
            transition: background-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
        }
        .kb-lock-led.is-on {
            background: #39d98a;
            box-shadow: 0 0 0 1px rgba(20, 83, 45, 0.45), 0 0 6px rgba(57, 217, 138, 0.72);
            opacity: 1;
        }

        .kb-arrows-inline {
            flex: 0 0 calc(var(--kb-unit) * 3.1 + var(--kb-gap) * 2);
            width: calc(var(--kb-unit) * 3.1 + var(--kb-gap) * 2);
            height: var(--kb-key-h);
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            grid-template-rows: 1fr 1fr;
            grid-template-areas: "left up right" "left down right";
            gap: 3px var(--kb-gap);
        }

        .kb-arrows-inline .kb-key {
            width: auto;
            height: auto;
            padding: 0;
            font-size: 1rem;
        }

        .kb-key.is-lit {
            color: #fff;
            background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff), var(--accent));
            border-color: var(--accent);
            box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 72%, #000), 0 0 0 3px var(--accent-light), 0 8px 16px color-mix(in srgb, var(--accent) 22%, transparent);
            transform: translateY(-1px);
        }

        .kb-key.is-lit:active,
        .kb-key.is-lit.is-pressed { transform: translateY(2px) scale(0.992); }

        .kb-key.is-lit.is-lit-secondary {
            color: var(--accent);
            background: var(--accent-soft);
            border-color: var(--accent);
            border-style: dashed;
            box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 35%, var(--kb-key-shadow));
            transform: none;
        }

        /* Pavé détaché : présent dans le DOM desktop, masqué par défaut. */
        .kb-numpad {
            width: calc(var(--kb-unit) * 4 + var(--kb-gap) * 3 + 32px);
            display: none;
            grid-template-columns: repeat(4, var(--kb-unit));
            grid-template-rows: repeat(6, var(--kb-key-h));
            grid-template-areas:
                "home end pageup pagedown"
                "lock divide multiply subtract"
                "n7 n8 n9 add"
                "n4 n5 n6 add"
                "n1 n2 n3 npenter"
                "n0 n0 decimal npenter";
            gap: var(--kb-gap);
            padding: calc(var(--kb-function-h) - 1px) 16px 16px;
        }

        .kb-profile-desktop .kb-numpad {
            margin-top: 24px;
            padding-top: calc(var(--kb-function-h) - 25px);
            background: var(--kb-chassis-bg);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }
        .kb-board.is-numpad-visible .kb-numpad { display: grid; }
        .kb-board .kb-numpad.is-numpad-exiting {
            display: grid;
            position: absolute;
            top: 0;
            left: calc(100% + 16px);
            pointer-events: none;
        }
        .kb-numpad .kb-key { width: auto; height: auto; padding: 0 3px; }
        .kb-numpad .kb-np-0 { width: auto; }
        .kb-np-tall { flex-direction: column; }
        .kb-np-lock {
            padding: 3px 5px;
            font-size: 0.58rem !important;
        }
        .kb-np-lock .kb-lock-label,
        .kb-np-lock .kb-lock-label > span {
            width: 100%;
            min-width: 0;
            white-space: normal;
            text-align: center;
            line-height: 1.02;
            overflow-wrap: anywhere;
        }
        .kb-np-num {
            font-size: 1rem;
            font-weight: 850;
            opacity: 0.32;
            transition: opacity 0.16s ease, transform 0.16s ease;
        }
        .kb-np-single .kb-np-num { opacity: 1; }
        .kb-np-nav {
            position: absolute;
            top: 3px;
            right: 4px;
            width: 15px;
            height: 15px;
            opacity: 1;
            transition: opacity 0.16s ease;
        }
        .kb-numpad .kb-key:has(.kb-np-num) { position: relative; }
        .kb-shell.is-num-lock .kb-np-num { opacity: 1; transform: scale(1.04); }
        .kb-shell.is-num-lock .kb-np-nav { opacity: 0.2; }
        .kb-key.is-lit .kb-np-num { opacity: 1; color: inherit; }
        .kb-key.is-lit .kb-np-nav { opacity: 0.32; color: inherit; }

        .kb-note {
            margin-top: 0.65rem;
            font-size: 0.8rem;
            color: var(--text-secondary);
            text-align: left;
        }
        .kb-note-dup {
            display: flex;
            align-items: center;
            gap: 0.45rem;
            width: fit-content;
            max-width: 100%;
            margin: 0.8rem auto 0;
            padding: 0.45rem 0.7rem;
            border: 1px solid rgba(143, 48, 84, 0.32);
            border-radius: 999px;
            background: rgba(255, 250, 253, 0.98);
            color: #172138;
            box-shadow: 0 5px 18px rgba(25, 35, 62, 0.16);
            font-size: 0.75rem;
            line-height: 1.35;
            font-weight: 600;
            opacity: 0;
            visibility: hidden;
            transform: translateY(5px);
            transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
        }
        [data-theme="dark"] .kb-note-dup {
            border-color: rgba(246, 150, 180, 0.5);
            background: rgba(27, 38, 60, 0.98);
            color: #f8fafc;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.38);
        }
        .kb-note-dup.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
        .kb-note-dup-icon { color: var(--accent); font-size: 1rem; line-height: 1; font-weight: 800; }
        .kb-shell[data-os="mac"] ~ .kb-note-dup { font-size: .65rem; }

        .kb-profile-mobile .kb-key {
            min-height: 32px;
            max-width: 100%;
            padding-inline: 2px;
            font-size: 0.72rem;
            line-height: 1;
            overflow: hidden;
            text-overflow: clip;
            box-shadow: 0 2px 0 var(--kb-key-shadow), 0 5px 8px var(--kb-key-drop), inset 0 1px 0 rgba(255, 255, 255, 0.42);
        }
        /* Sur mobile, chaque rangée distribue l'espace selon la largeur logique
           des touches. Le gap reste donc exactement identique entre deux touches,
           sans espace résiduel ajouté par `space-between`. */
        .kb-profile-mobile .kb-row {
            justify-content: flex-start;
            /* Réaffirme l'espacement du modèle face à l'ancien override
               responsive de 4 px chargé plus loin dans la feuille globale. */
            gap: var(--kb-gap);
        }
        .kb-profile-mobile .kb-row > .kb-key {
            flex: var(--kb-span, 1) 1 0;
            width: 0;
        }
        .kb-profile-mobile .kb-row > .kb-arrows-inline {
            flex: var(--kb-span, 3.1) 1 0;
            width: 0;
            min-width: 0;
        }
        /* Les demi-touches haut/bas doivent pouvoir occuper chacune la moitié
           du cluster : le min-height tactile général ne s'applique pas ici. */
        .kb-profile-mobile .kb-arrows-inline .kb-key { min-height: 0; }
        .kb-profile-mobile .kb-key > span { min-width: 0; max-width: 100%; }
        .kb-profile-mobile .kb-key.kb-mod { font-size: 0.52rem; }
        .kb-profile-mobile .kb-caps-key { font-size: 0.5rem; }
        .kb-profile-mobile .kb-tab-key {
            flex-direction: row;
            gap: 2px;
            font-size: 0.52rem;
        }
        .kb-profile-mobile .kb-tab-symbol {
            flex: 0 0 auto;
            font-size: 0.72rem;
            line-height: 1;
        }
        .kb-profile-mobile .kb-shift-key { font-size: 0.52rem; }
        .kb-profile-mobile .kb-shift-key .kb-mod-symbol { font-size: 0.72rem; }
        .kb-profile-mobile .kb-mobile-enter .kb-mobile-enter-symbol { font-size: 0.82rem; }
        .kb-profile-mobile .kb-mobile-enter .kb-mobile-enter-label {
            font-size: 0.47rem;
            letter-spacing: -0.015em;
        }
        .kb-profile-mobile .kb-mobile-backspace .kb-backspace-icon { font-size: 0.92rem; }
        .kb-profile-mobile .kb-number-row .kb-key { font-size: 0.68rem; }
        .kb-profile-mobile .kb-legends { gap: 2px; }
        .kb-profile-mobile .kb-legend-shift { font-size: 0.76em; }
        .kb-profile-mobile .kb-legend-alt,
        .kb-profile-mobile .kb-legend-alt-shift { right: 0; bottom: 0; font-size: 0.58em; }
        .kb-profile-mobile .kb-lock-led { top: 7px; right: 7px; }
        .kb-profile-mobile .kb-arrows-inline { height: var(--kb-key-h); }
        .kb-profile-mobile[data-os="mac"] .kb-mobile-bottom-row .kb-mod {
            font-size: 0.42rem;
            line-height: 0.96;
            white-space: normal;
        }
        .kb-profile-mobile .kb-key-word { display: none; }
        .kb-profile-mobile .kb-backspace-icon { display: inline; }

        .kb-key-help {
            position: fixed;
            z-index: 10020;
            max-width: min(240px, calc(100vw - 16px));
            padding: 6px 9px;
            border-radius: 7px;
            background: var(--text-primary);
            color: var(--bg-card);
            box-shadow: 0 6px 16px rgba(15,23,42,.25);
            font-size: 12px;
            font-weight: 700;
            line-height: 1.2;
            text-align: center;
            pointer-events: none;
        }

        .kb-profile-mobile .kb-settings-panel {
            width: 224px;
            transform-origin: bottom right;
        }

        /* La modale clavier est volontairement presque bord à bord en portrait.
           Avec son contenu à 360 px (largeur du modèle), le châssis occupe ainsi
           93–95 % de l'écran sur les téléphones courants, sans toucher les bords. */
        @media (max-width: 768px) {
            .modal-card.keyboard-modal {
                width: calc(100% - 1rem);
                padding: 1.25rem 0.35rem;
            }

            #keyboardModalBody {
                margin-inline: -0.25rem;
            }

            /* Seul le clavier profite de la largeur récupérée : le titre du
               raccourci et sa combinaison gardent la marge de lecture visible
               sur la référence. */
            #keyboardModalBody .kb-info {
                margin-inline: 0.65rem;
            }
        }

        @media (max-width: 480px) {
            .kb-config { gap: 0.28rem; }
            .kb-config-btn { min-height: 28px; padding: 0.24rem 0.52rem; font-size: 0.66rem; }
        }

        /* Dimensions ramenées au châssis de 360 px depuis la référence
           887 × 623 : touches 79 px, fonctions 66 px, entraxes verticaux 95 px. */
        .kb-shell.kb-profile-mobile {
            --kb-key-h: 32px;
            --kb-function-h: 27px;
            --kb-gap: 6.5px;
            --kb-radius: 3.8px;
        }
        .kb-profile-mobile .kb-main {
            padding: 39px 5.5px 13px;
        }
        .kb-profile-mobile .kb-controlbar {
            position: absolute;
            right: 6px;
            top: 8px;
            height: 21px;
        }
        .kb-profile-mobile .kb-viewport { margin-top: 0; }
        .kb-profile-mobile .kb-row { gap: 2.8px; }
        .kb-profile-mobile .kb-function-row { margin-bottom: 2px; }
        .kb-profile-mobile .kb-alpha-pair { gap: 2.8px; grid-template-columns: minmax(0, 1fr) 29.5px; }
        .kb-profile-mobile .kb-key {
            min-height: 0;
            padding: 0 1px;
            font-family: 'Arial Narrow', 'Segoe UI', Arial, sans-serif;
            font-size: 11.1px;
            font-weight: 525;
            /* Léger renfort également sur les polices non variables, qui
               arrondissent 500 et 525 vers la même graisse installée. */
            -webkit-text-stroke: 0.04px currentColor;
            gap: 3px;
            box-shadow: 0 1px 1px var(--kb-key-shadow), 0 3px 4px var(--kb-key-drop), inset 0 1px 0 rgba(255,255,255,.5);
        }
        [data-theme="dark"] .kb-profile-mobile .kb-key {
            box-shadow: 0 1px 1px var(--kb-key-shadow), 0 3px 4px var(--kb-key-drop), inset 0 1px 0 rgba(255,255,255,.07);
        }
        .kb-profile-mobile .kb-key.kb-mod { font-size: 8.3px; font-weight: 525; }
        .kb-profile-mobile .kb-key.kb-tab-key { font-size: 8px; }
        .kb-profile-mobile .kb-function-row .kb-key { height: 27px; font-size: 8.3px; }
        .kb-profile-mobile .kb-function-row .kb-key.kb-mod { font-size: 7.8px; }
        .kb-profile-mobile .kb-function-row .kb-multiline { font-size: 7.2px; line-height: 1.12; }
        .kb-profile-mobile .kb-number-row .kb-key { font-size: 10.2px; }
        .kb-profile-mobile .kb-legends { height: auto; min-height: 25px; gap: 2px; padding: 2px 1px; }
        .kb-profile-mobile .kb-legend-shift { font-size: 1em; opacity: 1; }
        .kb-profile-mobile .kb-legend-main { font-size: .88em; }
        .kb-profile-mobile .kb-legend-alt,
        .kb-profile-mobile .kb-legend-alt-shift { right: 0; bottom: -1px; font-size: 5.3px; opacity: 1; }
        .kb-profile-mobile .kb-mobile-enter { height: 70.5px; padding: 1px; gap: 5px; }
        .kb-profile-mobile .kb-mobile-enter .kb-mobile-enter-label { font-size: 7.8px; }
        .kb-profile-mobile .kb-mobile-enter .kb-mobile-enter-symbol { font-size: 21px; font-weight: 450; transform: scaleX(1.08); }
        .kb-profile-mobile .kb-shift-key .kb-mod-symbol { font-size: 16px; font-weight: 400; }
        .kb-profile-mobile .kb-mobile-symbol { width: 15px; height: 15px; flex: 0 0 15px; }
        .kb-profile-mobile .kb-mobile-backspace .kb-mobile-symbol { width: 19.5px; height: 19.5px; }
        .kb-profile-mobile .kb-lock-label { gap: 0; font-size: 8.2px; }
        .kb-profile-mobile .kb-lock-led { width: 4px; height: 4px; top: 3px; right: 3px; }
        /* Remonte la dernière rangée de 3 px sans supprimer l'entre-rangée de 6,5 px. */
        .kb-profile-mobile .kb-mobile-bottom-row { margin-top: 0.475px; align-items: end; }
        .kb-profile-mobile .kb-row > .kb-arrows-inline { flex: 3.8 1 0; }
        .kb-profile-mobile .kb-arrows-inline {
            height: 39.8px;
            gap: 2.8px;
            grid-template-rows: 17px 20px;
            grid-template-areas: '. up .' 'left down right';
        }
        .kb-profile-mobile .kb-arrows-inline .kb-key { font-size: 13.5px; font-weight: 420; }
        .kb-profile-mobile .kb-arrows-inline .kb-arrow-up,
        .kb-profile-mobile .kb-arrows-inline .kb-arrow-down { font-size: 12.8px; font-weight: 430; }
        .kb-profile-mobile .kb-arrows-inline .kb-arrow-down { height: 17px; align-self: end; }
        .kb-profile-mobile[data-os="mac"] .kb-mobile-bottom-row .kb-mod { font-size: 6.3px; line-height: 1.1; }
        .kb-profile-mobile[data-os="mac"] .kb-mobile-bottom-row .kb-mobile-fn { flex-direction: row; gap: 3px; font-size: 8px; }
        .kb-profile-mobile .kb-mobile-globe { width: 11px; height: 11px; flex: 0 0 11px; }
        .kb-profile-mobile .kb-mobile-option { width: 12px; height: 11px; flex: 0 0 11px; margin-bottom: 2px; }
        .kb-profile-mobile .kb-mobile-bottom-row .kb-mod-symbol { font-size: 12px; }
        .kb-profile-mobile .kb-mobile-bottom-row > .kb-key[data-kbid="fn"],
        .kb-profile-mobile .kb-mobile-bottom-row > .kb-key[data-kbid="ctrl"],
        .kb-profile-mobile .kb-mobile-bottom-row > .kb-key[data-kbid="alt"],
        .kb-profile-mobile .kb-mobile-bottom-row > .kb-key[data-kbid="space"] { font-size: 9px; }
        /* « Option » est le seul libellé qui frôle les bords à 320 px. */
        .kb-profile-mobile[data-os="mac"] .kb-mobile-bottom-row > .kb-key[data-kbid="alt"] > span {
            font-size: 8.2px;
            line-height: 1;
            letter-spacing: -0.02em;
        }
        .kb-profile-mobile .kb-os-icon, .kb-profile-mobile .kb-menu-icon { width: 14px; height: 14px; }
        .kb-profile-mobile .kb-key.is-lit {
            color: #fff;
            box-shadow: 0 1px 1px color-mix(in srgb,var(--accent) 70%,#000), 0 3px 5px var(--accent-light);
        }
        .kb-profile-mobile .kb-key.is-lit-secondary { color: var(--accent); }
        .kb-profile-mobile .kb-key:active, .kb-profile-mobile .kb-key.is-pressed { transform: translateY(2px); box-shadow: 0 1px 2px var(--kb-key-drop); }
        /* Le retour tactile est immédiat ; aucune interpolation de peinture
           sur toutes les touches lorsqu'un modificateur change de niveau. */
        @media (pointer: coarse) {
            .kb-key { transition: none; }
        }
        /* Une place stable pour les contacts, hors de la surface des touches.
           Les éléments restent en mémoire pendant leur bref affichage. */
        .kb-preview-rail {
            height: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            pointer-events: none;
            user-select: none;
            contain: layout paint;
        }
        .kb-profile-mobile .kb-preview-rail { height: 42px; }
        .kb-touch-preview {
            flex: 0 1 56px;
            min-width: 0;
            height: 36px;
            padding: 2px 6px;
            border: 1px solid var(--border-color, #94a3b8);
            border-radius: 8px;
            background: var(--bg-key, #fff);
            color: var(--text-primary, #172033);
            font: 600 24px/30px system-ui, sans-serif;
            text-align: center;
            pointer-events: none;
            user-select: none;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            contain: layout paint;
        }
        .kb-touch-preview[hidden] { display: none; }
        .kb-touch-preview-label { flex-basis: 88px; font-size: 13px; }

        /* Le symbole principal suit le même moteur que la bulle et la saisie.
           Les repères secondaires du desktop gardent une taille stable. */
        .kb-profile-mobile .kb-legends {
            height: 100%;
            min-height: 0;
            padding: 0;
            gap: 0;
        }
        .kb-profile-mobile .kb-legends > .kb-legend-main {
            position: static;
            display: block;
            max-width: 100%;
            font-size: 14.43px;
            font-weight: 700;
            line-height: 1;
            opacity: 1;
            transform: scaleY(1.06);
        }
        .kb-profile-mobile .kb-number-row .kb-legends > .kb-legend-main { font-size: 13.26px; }
        .kb-function-legend {
            display: inline-block;
            flex: 0 0 auto;
            font-family: Arial, sans-serif;
            font-size: 12px;
            font-weight: 700;
            font-style: normal;
            font-variant-numeric: tabular-nums;
            line-height: 1;
            letter-spacing: 0;
            -webkit-text-stroke: 0;
        }
        .kb-profile-mobile .kb-function-legend { font-size: 8.3px; transform: scaleY(1.07); }
        .kb-profile-mobile .kb-function-row [data-kbid="prtscn"] .kb-multiline { font-size: 8.64px; }
        .kb-profile-mobile .kb-shift-key > span:last-child { font-size: 9.96px; }
        .kb-profile-mobile .kb-caps-key .kb-lock-label { font-size: 9.84px; }
        .kb-profile-mobile .kb-legends > .kb-legend-shift,
        .kb-profile-mobile .kb-legends > .kb-legend-alt,
        .kb-profile-mobile .kb-legends > .kb-legend-alt-shift { display: none; }
        .kb-profile-mobile .kb-key.kb-shift-hint .kb-legends > .kb-legend-shift {
            display: block;
            font-size: 11.5px;
            font-weight: 700;
            line-height: 1;
            opacity: .92;
        }

        /* Le popover natif conserve la délégation d'événements et le thème,
           mais sort du découpage et de la mise à l'échelle de ses ancêtres. */
        .kb-settings-panel[popover]:popover-open {
            display: grid;
            position: fixed;
            inset: auto;
            margin: 0;
            width: min(244px, calc(100vw - 20px));
            padding: 10px;
            color: var(--text-primary);
            background: linear-gradient(145deg, #ffffff, #e1eeff);
            border-color: rgba(255,255,255,.74);
            backdrop-filter: blur(16px) saturate(140%);
            -webkit-backdrop-filter: blur(16px) saturate(140%);
            box-shadow: 0 10px 32px rgba(15,23,42,.22);
        }
        [data-theme="dark"] .kb-settings-panel[popover]:popover-open {
            background: linear-gradient(145deg, #2e425e, #0f1f37);
            border-color: rgba(185,208,238,.32);
        }
        @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
            .kb-numpad { background: #e5edf8; }
            [data-theme="dark"] .kb-numpad { background: #24344c; }
            .kb-settings-panel, .kb-settings-panel[popover]:popover-open { background: #f6faff; }
            [data-theme="dark"] .kb-settings-panel,
            [data-theme="dark"] .kb-settings-panel[popover]:popover-open { background: #142237; }
        }
        .kb-settings-panel[popover] .kb-config-btn { min-height: 27px; font-size: 11px; padding: 4px 7px; }
        .kb-settings-panel[popover] .kb-config-group { padding: 2px; border-radius: 8px; }
        .kb-settings-panel[popover] .kb-settings-title { font-size: 9px; }
        .kb-settings-panel[popover] .kb-os-icon { width: 12px; height: 12px; }
        .kb-profile-mobile .kb-settings-panel,
        .kb-profile-mobile .kb-settings-panel[popover]:popover-open {
            width: min(224px, calc(100vw - 20px));
            padding: 8px;
            gap: 3px;
        }
        .kb-profile-mobile .kb-settings-panel .kb-pref-row { gap: 3px; padding: 4px 2px 1px; }
        .kb-profile-mobile .kb-settings-panel .kb-feedback-control { padding-top: 22px; }
        .kb-profile-mobile .kb-settings-panel .kb-pref-row input[type="range"] { margin-bottom: 3px; }

        @media (prefers-reduced-motion: reduce) {
            .kb-feedback-bubble { transition: none; filter: none; }
            .kb-note-dup { transition: none; transform: none; }
            .kb-key,
            .kb-settings-panel,
            .kb-switch,
            .kb-switch > span { transition: none; }
        }
