/* Submenu — position:fixed set dynamically by JS so it never clips off-screen */
.ctx-sub {
    position: fixed;
    min-width: 200px;
    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;
    display: none;
    z-index: 100001;
    /* Same viewport cap as the root menu — a tall submenu (e.g. the style panel)
       must scroll rather than run off a short screen. */
    max-height: calc(100dvh - 12px);
    max-width: calc(100vw - 12px);
    overflow-y: auto;
    overflow-x: hidden;
}
.ctx-sub.ctx-sub-visible { display: block; }
/* Freshly (re)placed (js/ui/contextMenu/contextMenu.js positionSub): a row can land geometrically
   under a cursor that never moved to reach it, and the browser re-evaluates :hover the
   instant that happens — which would trigger a row's icon-motion/keycap-shake (below,
   and the `:hover .tip-key` rule) with no actual hover gesture behind it. Blocking
   pointer events keeps the cursor from "landing on" anything here until the user
   genuinely moves it, which is also what lifts this class (samplePointer). */
.ctx-sub.ctx-sub-fresh .ctx-item { pointer-events: none; }
/* Nested flyout (Copy Image / Download Image variant lists) — same box, one
   z-index higher so it always paints above the submenu it hangs off. */
.ctx-sub-nested {
    z-index: 100002;
    min-width: 240px;
}

/* Alt-hover export preview (js/ui/export/preview.js) — a small floating thumbnail
   near the cursor, shown only while Alt is held over a copy/download variant row. */
.ctx-preview-tip {
    position: fixed;
    z-index: 100010;
    display: none;
    padding: 4px;
    background: var(--bg-container);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.28);
    pointer-events: none;
}
.ctx-preview-tip.ctx-preview-visible { display: block; }
.ctx-preview-tip img {
    display: block;
    max-width: 220px;
    max-height: 220px;
    border-radius: 4px;
}

/* Checkbox items inside submenus */
.ctx-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    /* The menu's own rows (.ctx-item): not the bold 14px every <label> carries. */
    font-size: inherit;
    font-weight: normal;
    color: var(--text-main);
    user-select: none;
}
.ctx-checkbox-item:hover { background: var(--bg-coord-hover); }
/* The menu's one check box (.ctx-check): the app-wide accent box (controls.css) in the theme TEXT
   colour, the tick drawn inside the outline rather than filling it. */
.ctx-checkbox-item input[type=checkbox] { border-color: var(--text-main); cursor: pointer; }
.ctx-checkbox-item input[type=checkbox]:checked {
    background: var(--menu-tick) center / 12px no-repeat;
    border-color: var(--text-main);
}

/* Keyboard focus inside a flyout (contextMenu.js: the second → and Tab land on these):
   appearance:none dropped the browser's own ring on the boxes, so nothing showed which
   control had the keys (user report) — the accent ring the project rows wear. The chat
   textarea keeps its own focus border (#ctx-assist-input:focus). */
#ctx-menu input:focus-visible,
#ctx-menu select:focus-visible,
#ctx-menu button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Inline controls inside submenus */
.ctx-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    white-space: nowrap;
}
.ctx-row label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 90px;
    font-weight: normal;
}
.ctx-num {
    width: 56px;
    padding: 3px 5px;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    /* background-COLOR, not the shorthand: the shorthand resets the background-size/
       position that the input hover sweep (layout/shimmer.css) rides on, freezing its band. */
    background-color: var(--input-bg);
    color: var(--input-text);
    font-size: 13px;
}
.ctx-sel {
    flex: 1;
    padding: 3px 5px;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    background-color: var(--input-bg);   /* not the shorthand — keeps the hover sweep sizing */
    color: var(--input-text);
    font-size: 13px;
}
.ctx-color {
    width: 34px;
    height: 26px;
    padding: 1px;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    cursor: pointer;
}
.ctx-radio-group { display: flex; flex-direction: column; gap: 2px; padding: 4px 14px 6px; }
.ctx-radio-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.ctx-radio-item:hover { background: var(--bg-coord-hover); }
/* Context-menu radio: override the app-wide accent (see the appearance:none base rule at the
   top) so the ring + dot use the theme TEXT colour — a text-coloured dot on a transparent box,
   legible in both light and dark, matching the menu text. */
.ctx-radio-item input[type=radio] { border-color: var(--text-main); }
.ctx-radio-item input[type=radio]:checked {
    background-color: transparent;
    border-color: var(--text-main);
    background-image: radial-gradient(circle, var(--text-main) 0 2.6px, transparent 3.1px);
}
.ctx-sub-label {
    padding: 5px 14px 3px;
    font-size: 11px;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
/* tint color row — hidden until custom selected */
#ctx-tint-row { display: none; padding: 5px 14px 7px; align-items: center; gap: 8px; }
#ctx-tint-row.ctx-tint-visible { display: flex; }
#ctx-tint-row label { font-size: 12px; color: var(--text-muted); min-width: 70px; font-weight: normal; }
/* The x()/y() coordinate-formula fields. Scoped by the wrapper id so they keep the flat
   field face inside a menu — the shared input[type=text] sheen/hover rules outrank a
   bare class. */
#ctx-formula-inputs .ctx-formula-input {
    width: 140px;
    font-family: monospace;
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--input-text);
}
