/* Shortcut overlay and menu badges. Every rule is :where(), so any consumer rule wins. */
:where(.tabiot-shortcuts) {
    --tabiot-shortcuts-backdrop: rgba(15, 18, 24, .45);
    --tabiot-shortcuts-bg: var(--tsd-card-bg, var(--bs-body-bg, #ffffff));
    --tabiot-shortcuts-color: var(--tsd-body-color, var(--bs-body-color, #1a1d23));
    --tabiot-shortcuts-muted-color: var(--tsd-muted-color, var(--bs-secondary-color, #6b7280));
    --tabiot-shortcuts-border: var(--tsd-border-color, var(--bs-border-color, #e8eaed));
    --tabiot-shortcuts-radius: var(--tsd-card-radius, 12px);
    --tabiot-shortcuts-shadow: var(--tsd-card-shadow, 0 20px 50px -12px rgba(20, 24, 31, .35));
    --tabiot-shortcuts-width: 40rem;
    --tabiot-shortcuts-max-height: 80vh;
    --tabiot-shortcuts-z-index: 2000;
    --tabiot-shortcuts-font-size: .9rem;
    --tabiot-shortcuts-group-title-color: var(--tabiot-shortcuts-muted-color);
    --tabiot-shortcuts-active-accent: var(--tsd-primary, var(--bs-primary, #2563eb));
    --tabiot-shortcuts-key-bg: var(--tsd-surface-muted, var(--bs-tertiary-bg, #f3f4f6));
    --tabiot-shortcuts-key-color: var(--tabiot-shortcuts-color);
    --tabiot-shortcuts-key-border: var(--tabiot-shortcuts-border);
    --tabiot-shortcuts-key-radius: 6px;
    --tabiot-shortcuts-combo-gap: .75rem;
    --tabiot-shortcuts-key-font: var(--bs-font-monospace, ui-monospace, monospace);

    position: fixed;
    inset: 0;
    z-index: var(--tabiot-shortcuts-z-index);
    display: grid;
    place-items: center;
    padding: 1rem;
    background: var(--tabiot-shortcuts-backdrop);
    font-size: var(--tabiot-shortcuts-font-size);
}

:where(.tabiot-shortcuts__panel) {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(100%, var(--tabiot-shortcuts-width));
    max-height: var(--tabiot-shortcuts-max-height);
    /* Clips the scrolling body to the rounded corners; the header never scrolls */
    overflow: hidden;
    padding: 1.25rem 0;
    color: var(--tabiot-shortcuts-color);
    background: var(--tabiot-shortcuts-bg);
    border: 1px solid var(--tabiot-shortcuts-border);
    border-radius: var(--tabiot-shortcuts-radius);
    box-shadow: var(--tabiot-shortcuts-shadow);
    animation: tabiot-shortcuts-in .18s ease-out;
}

:where(.tabiot-shortcuts__panel:focus) {
    /* The panel takes the focus only to hold it inside the dialog: no ring on the container */
    outline: none;
}

:where(.tabiot-shortcuts__body) {
    display: grid;
    gap: 1rem;
    min-height: 0;
    overflow: auto;
    padding: 0 1.25rem;
}

:where(.tabiot-shortcuts__header) {
    flex: none;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

:where(.tabiot-shortcuts__title) {
    margin: 0;
    font-size: 1.1em;
}

:where(.tabiot-shortcuts__close) {
    padding: .1rem .5rem;
    font-size: 1.25em;
    line-height: 1;
    color: var(--tabiot-shortcuts-muted-color);
    background: none;
    border: 0;
    cursor: pointer;
}

:where(.tabiot-shortcuts__group) {
    display: grid;
    gap: .35rem;
    padding-left: .75rem;
    border-left: 3px solid transparent;
}

:where(.tabiot-shortcuts__group--active) {
    border-left-color: var(--tabiot-shortcuts-active-accent);
}

:where(.tabiot-shortcuts__group-title) {
    margin: 0;
    font-size: .8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--tabiot-shortcuts-group-title-color);
}

:where(.tabiot-shortcuts__list) {
    display: grid;
    gap: .25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

:where(.tabiot-shortcuts__item) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

:where(.tabiot-shortcuts__keys) {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .25rem var(--tabiot-shortcuts-combo-gap);
}

/* One key combination; several combos of the same action share a row */
:where(.tabiot-shortcuts__combo) {
    display: inline-flex;
    gap: .25rem;
}

/* Separator between alternative combos of the same action */
:where(.tabiot-shortcuts__or) {
    align-self: center;
    font-size: .8em;
    color: var(--tabiot-shortcuts-muted-color);
}

:where(.tabiot-shortcuts__key) {
    min-width: 1.6em;
    padding: .1em .45em;
    font-family: var(--tabiot-shortcuts-key-font);
    font-size: .85em;
    text-align: center;
    color: var(--tabiot-shortcuts-key-color);
    background: var(--tabiot-shortcuts-key-bg);
    border: 1px solid var(--tabiot-shortcuts-key-border);
    border-bottom-width: 2px;
    border-radius: var(--tabiot-shortcuts-key-radius);
}

:where(.tabiot-shortcuts__empty) {
    margin: 0;
    color: var(--tabiot-shortcuts-muted-color);
}

/* Numbers on menu items opened by a shortcut (inside DevExpress popups). */
:where([data-tabiot-shortcut-index]) {
    --tabiot-shortcuts-badge-bg: var(--tsd-primary, var(--bs-primary, #2563eb));
    --tabiot-shortcuts-badge-color: #ffffff;
    --tabiot-shortcuts-badge-size: 1.1rem;
    position: relative;
}

:where([data-tabiot-shortcut-index])::after {
    content: attr(data-tabiot-shortcut-index);
    position: absolute;
    top: 50%;
    right: .35rem;
    display: grid;
    place-items: center;
    width: var(--tabiot-shortcuts-badge-size);
    height: var(--tabiot-shortcuts-badge-size);
    font-size: .7rem;
    font-weight: 600;
    color: var(--tabiot-shortcuts-badge-color);
    background: var(--tabiot-shortcuts-badge-bg);
    border-radius: 50%;
    transform: translateY(-50%);
}

@keyframes tabiot-shortcuts-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

/* Grid row menu: label on the left, key hint aligned right with a minimum gap */
:where(.dxbl-context-menu-item-text:has(> .tabiot-shortcuts__menu-text)) {
    flex-grow: 1;
}

:where(.tabiot-shortcuts__menu-text) {
    display: flex;
    align-items: baseline;
    gap: var(--tabiot-shortcuts-hint-gap, 1.5rem);
    width: 100%;
}

:where(.tabiot-shortcuts__hint) {
    --tabiot-shortcuts-hint-color: var(--tsd-muted-color, var(--bs-secondary-color, #6b7280));
    margin-inline-start: auto;
    font-family: var(--bs-font-monospace, ui-monospace, monospace);
    font-size: .8em;
    color: var(--tabiot-shortcuts-hint-color);
    background: none;
    border: 0;
    box-shadow: none;
}

/* Leave room for the number badge while a menu is numbered */
:where([data-tabiot-shortcut-index] .tabiot-shortcuts__hint) {
    margin-inline-end: 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
    :where(.tabiot-shortcuts__panel) { animation: none; }
}
