@layer components {
  /* Inline menu (Ui::MenuComponent, controllers/menu_controller.js): 240 px, fixed so no scroll container clips it;
     the controller sets left and top. */
  .menu {
    position: fixed; inset: auto; margin: 0; z-index: 60; width: 240px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px);
    overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-float);
  }
  .menu[hidden] { display: none; }
  .menu-title {
    padding: 6px 8px 4px; color: var(--muted-foreground); font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .menu-heading {
    padding: 6px 8px 2px; color: var(--muted-foreground); font-size: 13px; font-weight: 500; letter-spacing: .04em;
    text-transform: uppercase;
  }
  .menu-separator { height: 1px; margin: 4px -4px; background: var(--border); }
  .menu-form { display: contents; }
  .menu-form[hidden], .menu-sub[hidden] { display: none; }
  /* Open in place, as the body of a sheet. */
  .menu--inline { position: static; width: auto; max-width: none; max-height: none; border: 0; box-shadow: none; background: transparent; }
  .menu--inline .menu-title { display: none; }
  .menu-trailing { flex: none; color: var(--muted-foreground); font-size: 13px; }
  .menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 6px 8px; border: 0;
    border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 14px; line-height: 1.3;
    text-align: left; text-decoration: none; cursor: pointer;
  }
  .menu-item svg { flex: none; color: var(--muted-foreground); }
  .menu-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .menu-item:hover, .menu-item:focus-visible { background: var(--muted); }
  .menu-item:active { background: var(--accent); }
  .menu-item:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: -2px; }
  .menu-item[aria-checked=true]::after { content: "✓" / ""; flex: none; margin-left: auto; }
  .menu-item[data-tone=danger], .menu-item[data-tone=danger] svg { color: var(--jx-no); }
  /* The 1 px keeps a fractional row edge from handing a finger's corner to the next row. */
  @media (pointer: coarse) { .menu-item { min-height: 44px; margin-bottom: 1px; } }

  /* A 150 ms fade on opening; a reader who asked for no motion sees none. */
  @media (prefers-reduced-motion: no-preference) {
    .menu { animation: menu-in 150ms var(--ease-out); }
    @keyframes menu-in { from { opacity: 0; } }
  }
}
