/* ── Custom context menu ── */
#ctx-menu {
    position: fixed;
    z-index: 99999;
    min-width: 210px;
    background: var(--bg-container);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.22);
    padding: 5px 0;
    font-size: 13.5px;
    color: var(--text-main);
    user-select: none;
    display: none;
    /* Never exceed the viewport: on short screens (landscape phones, small
       tablets) the tall menu would otherwise run off the bottom with its lower
       items unreachable. Scroll instead. Submenus are position:fixed (below) so
       this overflow does not clip them. */
    max-height: calc(100dvh - 12px);
    max-width: calc(100vw - 12px);
    overflow-y: auto;
    overflow-x: hidden;
}
#ctx-menu.ctx-open { display: block; }

.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    border-radius: 4px;
    margin: 0 4px;
    position: relative;
    white-space: nowrap;
    transition: background 0.12s;
}
/* .ctx-kb: the row the keyboard walk is on (contextMenu.js) — the hover look. */
.ctx-item:hover, .ctx-item.ctx-open-sub, .ctx-item.ctx-kb {
    background: var(--bg-coord-hover);
}
.ctx-item .ctx-icon, .accent-dd-opt .ctx-icon {
    width: 16px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.ctx-item .ctx-label, .accent-dd-opt .ctx-label { flex: 1; min-width: 0; }
/* Trailing hotkey/arrow are fixed-width flex items (not auto-margin) so hotkey/arrow
   always land on the same right edge regardless of which are present. .ctx-arrow is
   always in the markup (contextMenu.js ctxArrow()), empty when there's no submenu, so
   its 12px stays reserved either way. */
.ctx-item .ctx-arrow {
    flex: 0 0 12px;
    width: 12px;
    opacity: 0.55;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}
/* A list with no flyout row gives the arrow's column up (desktop menuRowPolish.hpp flatMenu). */
:is(#ctx-menu, .ctx-sub):not(:has(> .ctx-item > .ctx-arrow:not(:empty))) > .ctx-item > .ctx-arrow { display: none; }
.ctx-sep {
    height: 1px;
    background: var(--border-main);
    margin: 5px 10px;
}
/* Every check in the menu is one box (the flyouts' checkboxes in submenu.css too): an empty
   square when off, the tick inside it when on, in the menu's text colour, not the accent. */
.ctx-check {
    box-sizing: border-box;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border: 1px solid var(--text-main);
    border-radius: 3px;
    color: var(--text-main);
}
.ctx-check > * { display: none; }
.ctx-check:not(:empty) { background: var(--menu-tick) center / 12px no-repeat; }

